@seedprotocol/sdk 0.6.6 → 0.6.8
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-BGxb4Qod.js → BasePathResolver-B6CKqoKw.js} +137 -4
- package/dist/BasePathResolver-B6CKqoKw.js.map +1 -0
- package/dist/{index-CJNKYI37.js → ClientManager-ChcmUL47.js} +1928 -5543
- package/dist/ClientManager-ChcmUL47.js.map +1 -0
- package/dist/{ModelProperty-Bvg9cJcd.js → ModelProperty-D79uV42p.js} +42 -36
- package/dist/ModelProperty-D79uV42p.js.map +1 -0
- package/dist/{Schema-BNJBY80k.js → Schema-a8uO-hIZ.js} +48 -47
- package/dist/Schema-a8uO-hIZ.js.map +1 -0
- package/dist/{SchemaValidationService-aqXkwXTr.js → SchemaValidationService-Y49vqast.js} +16 -12
- package/dist/SchemaValidationService-Y49vqast.js.map +1 -0
- package/dist/{backfillMetadataPropertyIds-DYkvoOMz.js → backfillMetadataPropertyIds-CBsf7LnU.js} +6 -3
- package/dist/{backfillMetadataPropertyIds-DYkvoOMz.js.map → backfillMetadataPropertyIds-CBsf7LnU.js.map} +1 -1
- package/dist/cjs/{ModelProperty-alntkSnH.js → ModelProperty-D9FGaGuE.js} +25 -20
- package/dist/cjs/ModelProperty-D9FGaGuE.js.map +1 -0
- package/dist/cjs/{Schema-ByFv6fcb.js → Schema-BiJIPLEL.js} +29 -27
- package/dist/cjs/Schema-BiJIPLEL.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-D55MWsxv.js → SchemaValidationService-DtYs_CNY.js} +9 -6
- package/dist/cjs/SchemaValidationService-DtYs_CNY.js.map +1 -0
- package/dist/cjs/{backfillMetadataPropertyIds-DrrL5RqD.js → backfillMetadataPropertyIds-2XaN3b9S.js} +7 -5
- package/dist/cjs/{backfillMetadataPropertyIds-DrrL5RqD.js.map → backfillMetadataPropertyIds-2XaN3b9S.js.map} +1 -1
- package/dist/cjs/{eas-D2E3_i_c.js → eas-CMNppmGE.js} +32 -6
- package/dist/cjs/eas-CMNppmGE.js.map +1 -0
- package/dist/cjs/{getItem-B2zLVB_l.js → getItem-B6jEINjW.js} +6 -4
- package/dist/cjs/{getItem-B2zLVB_l.js.map → getItem-B6jEINjW.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-Bv94k4ak.js → getPublishPayload-D5DhLGvN.js} +66 -60
- package/dist/cjs/getPublishPayload-D5DhLGvN.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CSbHUxYk.js → getPublishUploads-DMhCCKYF.js} +21 -13
- package/dist/cjs/getPublishUploads-DMhCCKYF.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-CMhXKQHz.js → getSegmentedItemProperties-CU8rtBAo.js} +3 -51
- package/dist/cjs/getSegmentedItemProperties-CU8rtBAo.js.map +1 -0
- package/dist/cjs/{index-D-9WglxG.js → index-CSNtEnbF.js} +5986 -5389
- package/dist/cjs/index-CSNtEnbF.js.map +1 -0
- package/dist/cjs/{index-pSLjO-ch.js → index-DPp9rdRL.js} +10 -6
- package/dist/cjs/index-DPp9rdRL.js.map +1 -0
- package/dist/cjs/{property-gUK2PijH.js → property-DlKiAWt4.js} +11 -7
- package/dist/cjs/{property-gUK2PijH.js.map → property-DlKiAWt4.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-CYtl7VTD.js → syncDbWithEas-C6n34o_Q.js} +14 -8
- package/dist/cjs/syncDbWithEas-C6n34o_Q.js.map +1 -0
- package/dist/{configurePlatform-bGvKBBQy.js → configurePlatform-CE0Vew17.js} +6 -3
- package/dist/{configurePlatform-bGvKBBQy.js.map → configurePlatform-CE0Vew17.js.map} +1 -1
- package/dist/db/drizzle/0014_add_error_code_to_publish_processes.sql +1 -0
- package/dist/db/drizzle/meta/0014_snapshot.json +1269 -0
- package/dist/db/drizzle/meta/_journal.json +7 -0
- package/dist/{db-YiH_kIpE.js → db-WbrzEf7c.js} +266 -53
- package/dist/db-WbrzEf7c.js.map +1 -0
- package/dist/{eas-1nUCcmeh.js → eas-CfYCu4IX.js} +9 -6
- package/dist/eas-CfYCu4IX.js.map +1 -0
- package/dist/generateId-BopUwD8F.js +9 -0
- package/dist/generateId-BopUwD8F.js.map +1 -0
- package/dist/{getItem-Bb8bTYzY.js → getItem-Br-bGNFO.js} +12 -10
- package/dist/{getItem-Bb8bTYzY.js.map → getItem-Br-bGNFO.js.map} +1 -1
- package/dist/{getPublishPayload-BHw8mPSb.js → getPublishPayload-BIrTVUxb.js} +72 -65
- package/dist/getPublishPayload-BIrTVUxb.js.map +1 -0
- package/dist/{getPublishUploads-BYhckxFl.js → getPublishUploads-C6cDeZdz.js} +22 -13
- package/dist/getPublishUploads-C6cDeZdz.js.map +1 -0
- package/dist/{getSegmentedItemProperties-B73nMPBv.js → getSegmentedItemProperties-BmKE71vU.js} +5 -5
- package/dist/{getSegmentedItemProperties-B73nMPBv.js.map → getSegmentedItemProperties-BmKE71vU.js.map} +1 -1
- package/dist/index-280bL-n4.js +1122 -0
- package/dist/index-280bL-n4.js.map +1 -0
- package/dist/{index-DzgMt8ba.js → index-ClSv5pTA.js} +17 -14
- package/dist/index-ClSv5pTA.js.map +1 -0
- package/dist/{index-C_5xwOPQ.js → index-Djd3667v.js} +2 -2
- package/dist/index-Djd3667v.js.map +1 -0
- package/dist/index-HRHkbVQd.js +3492 -0
- package/dist/index-HRHkbVQd.js.map +1 -0
- package/dist/{index.node-ZLiBj9Cu.js → index.node-DBtQkEfz.js} +8 -7
- package/dist/index.node-DBtQkEfz.js.map +1 -0
- package/dist/main.cjs +10 -4
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +43 -43
- package/dist/main.js.map +1 -1
- package/dist/model-DGMe-TTm.js +25 -0
- package/dist/model-DGMe-TTm.js.map +1 -0
- package/dist/node.js +21 -17
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +162 -63
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +5 -5
- package/dist/{property-Dcb50seV.js → property-CQjuZ4JW.js} +20 -17
- package/dist/property-CQjuZ4JW.js.map +1 -0
- package/dist/seedSchema/PublishProcessSchema.ts +1 -0
- package/dist/src/Item/Item.d.ts +6 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +10 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +1 -1
- package/dist/src/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/db/embeddedMigrations.d.ts +17 -0
- package/dist/src/browser/db/embeddedMigrations.d.ts.map +1 -0
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/EasClient.d.ts +2 -1
- package/dist/src/browser/helpers/EasClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +18 -3
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +6 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts +4 -0
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/client/nodeEndpointDefaults.d.ts +8 -0
- package/dist/src/client/nodeEndpointDefaults.d.ts.map +1 -0
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/eas.d.ts +2 -2
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/index.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +1 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -2
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +4 -0
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts +9 -2
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/crypto.d.ts +3 -2
- package/dist/src/helpers/crypto.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +6 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ensureImageLocal.d.ts +24 -0
- package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -0
- package/dist/src/helpers/ethereumUtils.d.ts.map +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +10 -2
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/localDbChain.d.ts +22 -0
- package/dist/src/helpers/localDbChain.d.ts.map +1 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts +9 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/property/index.d.ts +12 -0
- package/dist/src/helpers/property/index.d.ts.map +1 -1
- package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +8 -0
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/easLodashHook.d.ts +2 -0
- package/dist/src/node/easLodashHook.d.ts.map +1 -0
- package/dist/src/node/easLodashRegister.d.ts +2 -0
- package/dist/src/node/easLodashRegister.d.ts.map +1 -0
- package/dist/src/node/helpers/FileManager.d.ts +2 -1
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +2 -1
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/seedSchema/PublishProcessSchema.d.ts +19 -0
- package/dist/src/seedSchema/PublishProcessSchema.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts +4 -0
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +15 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-B0RUeDuj.js → syncDbWithEas-CuARXfyN.js} +24 -18
- package/dist/syncDbWithEas-CuARXfyN.js.map +1 -0
- package/dist/{updateSeedRevokedAt-D5ZbBehZ.js → updateSeedRevokedAt-CBcLfHWs.js} +2 -2
- package/dist/{updateSeedRevokedAt-D5ZbBehZ.js.map → updateSeedRevokedAt-CBcLfHWs.js.map} +1 -1
- package/package.json +12 -8
- package/src/node/easLodashHook.js +22 -0
- package/src/node/easLodashRegister.js +13 -0
- package/dist/BasePathResolver-BGxb4Qod.js.map +0 -1
- package/dist/ModelProperty-Bvg9cJcd.js.map +0 -1
- package/dist/Schema-BNJBY80k.js.map +0 -1
- package/dist/SchemaValidationService-aqXkwXTr.js.map +0 -1
- package/dist/cjs/ModelProperty-alntkSnH.js.map +0 -1
- package/dist/cjs/Schema-ByFv6fcb.js.map +0 -1
- package/dist/cjs/SchemaValidationService-D55MWsxv.js.map +0 -1
- package/dist/cjs/eas-D2E3_i_c.js.map +0 -1
- package/dist/cjs/getPublishPayload-Bv94k4ak.js.map +0 -1
- package/dist/cjs/getPublishUploads-CSbHUxYk.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-CMhXKQHz.js.map +0 -1
- package/dist/cjs/index-D-9WglxG.js.map +0 -1
- package/dist/cjs/index-pSLjO-ch.js.map +0 -1
- package/dist/cjs/syncDbWithEas-CYtl7VTD.js.map +0 -1
- package/dist/constants-Bre6dTJR.js +0 -122
- package/dist/constants-Bre6dTJR.js.map +0 -1
- package/dist/constants-CTs2RUrM.js +0 -657
- package/dist/constants-CTs2RUrM.js.map +0 -1
- package/dist/db-YiH_kIpE.js.map +0 -1
- package/dist/eas-1nUCcmeh.js.map +0 -1
- package/dist/getPublishPayload-BHw8mPSb.js.map +0 -1
- package/dist/getPublishUploads-BYhckxFl.js.map +0 -1
- package/dist/index-CJNKYI37.js.map +0 -1
- package/dist/index-C_5xwOPQ.js.map +0 -1
- package/dist/index-DzgMt8ba.js.map +0 -1
- package/dist/index.node-ZLiBj9Cu.js.map +0 -1
- package/dist/property-Dcb50seV.js.map +0 -1
- package/dist/seedSchema/AppStateSchema.d.ts +0 -82
- package/dist/seedSchema/AppStateSchema.d.ts.map +0 -1
- package/dist/seedSchema/ConfigSchema.d.ts +0 -101
- package/dist/seedSchema/ConfigSchema.d.ts.map +0 -1
- package/dist/seedSchema/MetadataSchema.d.ts +0 -422
- package/dist/seedSchema/MetadataSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchema.d.ts +0 -243
- package/dist/seedSchema/ModelSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchemaSchema.d.ts +0 -61
- package/dist/seedSchema/ModelSchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelUidSchema.d.ts +0 -64
- package/dist/seedSchema/ModelUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/PropertyUidSchema.d.ts +0 -64
- package/dist/seedSchema/PropertyUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/SchemaSchema.d.ts +0 -169
- package/dist/seedSchema/SchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/SeedSchema.d.ts +0 -192
- package/dist/seedSchema/SeedSchema.d.ts.map +0 -1
- package/dist/seedSchema/VersionSchema.d.ts +0 -194
- package/dist/seedSchema/VersionSchema.d.ts.map +0 -1
- package/dist/seedSchema/index.d.ts +0 -14
- package/dist/seedSchema/index.d.ts.map +0 -1
- package/dist/syncDbWithEas-B0RUeDuj.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert Model.properties array to object format (for backward compatibility)
|
|
3
|
+
* This replaces the old model.schema getter
|
|
4
|
+
*/
|
|
5
|
+
function modelPropertiesToObject(properties) {
|
|
6
|
+
const schemaObj = {};
|
|
7
|
+
for (const property of properties) {
|
|
8
|
+
const propContext = property._getSnapshotContext();
|
|
9
|
+
if (propContext.name) {
|
|
10
|
+
schemaObj[propContext.name] = {
|
|
11
|
+
dataType: propContext.dataType,
|
|
12
|
+
ref: propContext.refModelName || propContext.ref,
|
|
13
|
+
refValueType: propContext.refValueType,
|
|
14
|
+
storageType: propContext.storageType,
|
|
15
|
+
localStorageDir: propContext.localStorageDir,
|
|
16
|
+
filenameSuffix: propContext.filenameSuffix,
|
|
17
|
+
required: propContext.required,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return schemaObj;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { modelPropertiesToObject };
|
|
25
|
+
//# sourceMappingURL=model-DGMe-TTm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-DGMe-TTm.js","sources":["../../src/helpers/model.ts"],"sourcesContent":["import { ModelProperty } from '@/ModelProperty/ModelProperty'\n\n/**\n * Convert Model.properties array to object format (for backward compatibility)\n * This replaces the old model.schema getter\n */\nexport function modelPropertiesToObject(properties: ModelProperty[]): { [propertyName: string]: any } {\n const schemaObj: { [propertyName: string]: any } = {}\n \n for (const property of properties) {\n const propContext = property._getSnapshotContext()\n if (propContext.name) {\n schemaObj[propContext.name] = {\n dataType: propContext.dataType,\n ref: propContext.refModelName || propContext.ref,\n refValueType: propContext.refValueType,\n storageType: propContext.storageType,\n localStorageDir: propContext.localStorageDir,\n filenameSuffix: propContext.filenameSuffix,\n required: propContext.required,\n }\n }\n }\n \n return schemaObj\n}\n\n"],"names":[],"mappings":"AAEA;;;AAGG;AACG,SAAU,uBAAuB,CAAC,UAA2B,EAAA;IACjE,MAAM,SAAS,GAAoC,EAAE;AAErD,IAAA,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;AACjC,QAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,mBAAmB,EAAE;AAClD,QAAA,IAAI,WAAW,CAAC,IAAI,EAAE;AACpB,YAAA,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;AAC9B,gBAAA,GAAG,EAAE,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,GAAG;gBAChD,YAAY,EAAE,WAAW,CAAC,YAAY;gBACtC,WAAW,EAAE,WAAW,CAAC,WAAW;gBACpC,eAAe,EAAE,WAAW,CAAC,eAAe;gBAC5C,cAAc,EAAE,WAAW,CAAC,cAAc;gBAC1C,QAAQ,EAAE,WAAW,CAAC,QAAQ;aAC/B;QACH;IACF;AAEA,IAAA,OAAO,SAAS;AAClB;;"}
|
package/dist/node.js
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import { enableMapSet } from 'immer';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
export {
|
|
4
|
-
import { M as ModelPropertyDataTypes, P as Property } from './
|
|
5
|
-
export { B as Boolean, a as Date, I as Image, J as Json, L as List, N as Number, R as Relation, j as Text
|
|
3
|
+
export { M as Model } from './index-HRHkbVQd.js';
|
|
4
|
+
import { M as ModelPropertyDataTypes, P as Property, s as addModelsToDb } from './db-WbrzEf7c.js';
|
|
5
|
+
export { B as Boolean, a as Date, I as Image, J as Json, L as List, N as Number, R as Relation, j as Text } from './db-WbrzEf7c.js';
|
|
6
6
|
import 'pluralize';
|
|
7
|
-
import { a as BaseDb } from './BasePathResolver-
|
|
8
|
-
export { t as BasePathResolver, c as appState, e as config, b as metadata, j as modelUids, m as models, r as seeds, v as versions } from './BasePathResolver-
|
|
7
|
+
import { a as BaseDb } from './BasePathResolver-B6CKqoKw.js';
|
|
8
|
+
export { t as BasePathResolver, y as INIT_SCRIPT_SUCCESS_MESSAGE, S as SCHEMA_TS, c as appState, e as config, b as metadata, j as modelUids, m as models, r as seeds, v as versions } from './BasePathResolver-B6CKqoKw.js';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export { I as Item, f as ItemProperty, h as ItemPropertySaveValidationError, C as client, i as getRefValueType, j as importJsonSchema, k as loadSchemaFromFile, m as readJsonImportFile, s as syncSchemaFromSource, t as transformImportToSchemaFile } from './ClientManager-ChcmUL47.js';
|
|
11
|
+
import { c as createPlatformServices } from './index.node-DBtQkEfz.js';
|
|
12
|
+
export { D as Db, F as FileManager, P as PathResolver, r as resolveSdkDrizzleMigrationsDir } from './index.node-DBtQkEfz.js';
|
|
13
|
+
export { e as eventEmitter, g as getCorrectId, i as isPublishedSeedRef, n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString } from './index-280bL-n4.js';
|
|
12
14
|
import yaml from 'js-yaml';
|
|
13
15
|
import fs__default, { readFileSync } from 'fs';
|
|
14
|
-
import { c as addModelsToDb } from './db-YiH_kIpE.js';
|
|
15
16
|
import { execSync } from 'child_process';
|
|
16
17
|
import path from 'path';
|
|
17
|
-
|
|
18
|
-
import { configurePlatform } from './configurePlatform-bGvKBBQy.js';
|
|
18
|
+
import { configurePlatform } from './configurePlatform-CE0Vew17.js';
|
|
19
19
|
import 'xstate';
|
|
20
20
|
import 'debug';
|
|
21
|
+
import './generateId-BopUwD8F.js';
|
|
21
22
|
import 'nanoid';
|
|
22
23
|
import 'nanoid-dictionary';
|
|
23
|
-
import '
|
|
24
|
-
import 'rxjs';
|
|
25
|
-
import 'lodash-es';
|
|
24
|
+
import './model-DGMe-TTm.js';
|
|
26
25
|
import 'drizzle-orm/casing';
|
|
27
|
-
import '@seedprotocol/arweave';
|
|
28
|
-
import 'js-sha3';
|
|
29
|
-
import '@seedprotocol/query';
|
|
30
26
|
import '@sinclair/typebox';
|
|
27
|
+
import 'lodash-es';
|
|
31
28
|
import 'drizzle-orm/sqlite-core';
|
|
29
|
+
import '@seedprotocol/arweave';
|
|
30
|
+
import '@seedprotocol/eas';
|
|
31
|
+
import '@noble/hashes/sha3';
|
|
32
|
+
import '@noble/hashes/utils';
|
|
33
|
+
import '@seedprotocol/query';
|
|
34
|
+
import 'rxjs';
|
|
32
35
|
import 'fs/promises';
|
|
36
|
+
import 'url';
|
|
33
37
|
import 'node:url';
|
|
34
|
-
import './index-
|
|
38
|
+
import './index-Djd3667v.js';
|
|
35
39
|
import '@libsql/client';
|
|
36
40
|
import 'drizzle-orm/libsql';
|
|
37
41
|
import 'drizzle-orm/libsql/migrator';
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sources":["../../src/imports/markdown.ts","../../src/node/webpack/index.ts","../../src/node/helpers/scripts.ts","../../src/node/index.ts"],"sourcesContent":["import yaml from 'js-yaml'\nimport { readFileSync } from 'fs'\nimport { Property, ModelPropertyDataTypes } from '@/Schema'\nimport { ModelDefinitions } from '@/types'\nimport { addModelsToDb } from '../helpers/db'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport type { Model } from '@/Model/Model'\n\n/**\n * Configuration structure expected in markdown frontmatter\n */\ntype SeedConfig = {\n seed: {\n model: string\n properties: {\n [propertyName: string]: {\n type: string\n target?: string\n /** For List: element type when primitive (e.g. 'Text', 'Number'). Use target for list of relations. */\n itemsType?: string\n }\n }\n }\n}\n\n/**\n * Parses markdown frontmatter from a file\n * @param filePath Path to the markdown file\n * @returns The parsed frontmatter as an object, or null if no frontmatter found\n */\nexport const parseMarkdownFrontmatter = (\n filePath: string,\n): Record<string, any> | null => {\n const content = readFileSync(filePath, 'utf-8')\n \n // Check for frontmatter delimiters (more flexible regex)\n // Matches --- at start, optional whitespace, content, ---, optional whitespace\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)\\n---(\\s*\\n|$)/\n const match = content.match(frontmatterRegex)\n \n if (!match) {\n return null\n }\n \n const frontmatterYaml = match[1]\n \n try {\n const frontmatter = yaml.load(frontmatterYaml) as Record<string, any>\n return frontmatter\n } catch (error) {\n throw new Error(\n `Failed to parse YAML frontmatter in ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Converts a seed config from frontmatter to ModelDefinitions format\n * @param config The seed configuration from frontmatter\n * @returns ModelDefinitions object ready to be saved to database\n */\nexport const processSeedConfig = (config: SeedConfig): ModelDefinitions => {\n if (!config.seed) {\n throw new Error('No seed configuration found in frontmatter')\n }\n \n const { model: modelName, properties: propertiesConfig } = config.seed\n \n if (!modelName) {\n throw new Error('Model name is required in seed configuration')\n }\n \n if (!propertiesConfig || Object.keys(propertiesConfig).length === 0) {\n throw new Error('Properties are required in seed configuration')\n }\n \n // Convert property configs to Property definitions\n const schema: Record<string, any> = {}\n \n for (const [propertyName, propertyConfig] of Object.entries(propertiesConfig)) {\n const { type, target, itemsType } = propertyConfig\n \n if (!type) {\n throw new Error(`Property type is required for ${propertyName}`)\n }\n \n // Map the type to Property constructor\n switch (type) {\n case ModelPropertyDataTypes.Text:\n schema[propertyName] = Property.Text()\n break\n case ModelPropertyDataTypes.Number:\n schema[propertyName] = Property.Number()\n break\n case ModelPropertyDataTypes.Boolean:\n schema[propertyName] = Property.Boolean()\n break\n case ModelPropertyDataTypes.Date:\n schema[propertyName] = Property.Date()\n break\n case ModelPropertyDataTypes.Image:\n schema[propertyName] = Property.Image()\n break\n case ModelPropertyDataTypes.Json:\n schema[propertyName] = Property.Json()\n break\n case ModelPropertyDataTypes.File:\n schema[propertyName] = Property.File()\n break\n case ModelPropertyDataTypes.Relation:\n if (!target) {\n throw new Error(\n `Target model is required for Relation property ${propertyName}`,\n )\n }\n schema[propertyName] = Property.Relation(target)\n break\n case ModelPropertyDataTypes.List:\n if (itemsType) {\n // List of primitives: itemsType = 'Text', 'Number', etc.\n if (itemsType === ModelPropertyDataTypes.Relation && target) {\n schema[propertyName] = Property.List('Relation', target)\n } else if (itemsType !== ModelPropertyDataTypes.Relation) {\n schema[propertyName] = Property.List(itemsType as any)\n } else {\n throw new Error(\n `List of relations requires target model for property ${propertyName}`,\n )\n }\n } else if (target) {\n // Backward compat: target = model name for list of relations\n schema[propertyName] = Property.List('Relation', target)\n } else {\n throw new Error(\n `List property ${propertyName} requires either itemsType (e.g. 'Text') or target (model name for list of relations)`,\n )\n }\n break\n default:\n throw new Error(\n `Unknown property type: ${type} for property ${propertyName}`,\n )\n }\n }\n \n // Create a mock ModelClass structure that matches ModelDefinitions\n // This is a simplified version that works with addModelsToInternalDb\n const modelClass = {\n schema,\n create: async () => {\n throw new Error('Model.create() should not be called directly')\n },\n originalConstructor: class {},\n }\n \n return {\n [modelName]: modelClass as any as Model,\n }\n}\n\n/**\n * Reads a markdown file, parses frontmatter, and saves models/properties to database\n * @param filePath Path to the markdown file\n * @param db Database instance (BetterSQLite3Database or SqliteRemoteDatabase)\n * @returns The created ModelDefinitions\n */\nexport const saveModelsFromMarkdown = async (\n filePath: string,\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n): Promise<ModelDefinitions> => {\n // Parse frontmatter\n const frontmatter = parseMarkdownFrontmatter(filePath)\n \n if (!frontmatter) {\n throw new Error(`No frontmatter found in ${filePath}`)\n }\n \n // Validate and process seed config\n const seedConfig = frontmatter as SeedConfig\n const modelDefinitions = processSeedConfig(seedConfig)\n \n // Save to database\n await addModelsToDb(modelDefinitions, undefined, undefined, undefined)\n \n return modelDefinitions\n}\n","/**\n * Webpack / Next.js config helper for Seed Protocol apps.\n */\nexport const withSeed = (config: any, webpack: any, isServer: boolean) => {\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/node:/, (resource: { request: string }) => {\n resource.request = resource.request.replace(/^node:/, '')\n }),\n )\n\n if (!isServer) {\n config.resolve.alias['fs'] = '@zenfs/core'\n config.resolve.alias['node:fs'] = '@zenfs/core'\n config.resolve.alias['node:path'] = 'path-browserify'\n config.resolve.alias['path'] = 'path-browserify'\n }\n\n if (isServer) {\n config.externals.push('@sqlite.org/sqlite-wasm')\n config.externals.push('chokidar')\n config.externals.push('arweave')\n }\n\n return config\n}\n","import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const commandExists = (command: string): boolean => {\n try {\n execSync(`which ${command}`, { stdio: 'ignore' })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Finds the seed binary path, trying multiple locations\n * @returns The path to the seed binary, or null if not found\n */\nexport const findSeedBinary = (): string | null => {\n const cwd = process.cwd()\n\n const possiblePaths = [\n path.join(cwd, 'node_modules', '.bin', 'seed'),\n path.join(cwd, 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n ]\n\n for (const binPath of possiblePaths) {\n if (fs.existsSync(binPath)) {\n return binPath\n }\n }\n\n return null\n}\n\n/**\n * Ensures the Node app DB exists and SDK migrations are applied.\n * (Formerly `runSeedInit`; CLI spawn / npx fallbacks archived under docs/archive/commented/.)\n */\nexport const ensureNodeDbSchema = async (\n _schemaFileDir?: string,\n appFilesDirPath?: string\n): Promise<void> => {\n if (!appFilesDirPath) {\n throw new Error('ensureNodeDbSchema requires appFilesDirPath')\n }\n\n await BaseDb.prepareDb(appFilesDirPath)\n}\n\n/** @deprecated Use ensureNodeDbSchema */\nexport const runSeedInit = ensureNodeDbSchema\n","import { enableMapSet } from 'immer'\n\n// Core schema exports\nexport {\n Model,\n Property,\n Image,\n List,\n Text,\n Json,\n Relation,\n Boolean,\n Number,\n Date,\n} from '../Schema'\n\n// Core classes\nexport { Item } from '../Item/Item'\nexport { ItemProperty } from '../ItemProperty/ItemProperty'\n\n// Node.js specific exports\nexport { FileManager } from './helpers/FileManager'\nexport { Db, resolveSdkDrizzleMigrationsDir } from './db/Db'\n\n// Schema exports\nexport { models, versions, seeds, metadata, appState, config, modelUids } from '../seedSchema'\n\n// Model access - use Model static methods instead\n// Models are accessible via Model.all(), Model.getById(), Model.getByName(), etc.\n\n// Helper exports\nexport { getCorrectId } from '../helpers'\n\n// Import exports\nexport * from '../imports'\n\n// Event bus\nexport { eventEmitter } from '../eventBus'\n\n// Webpack helper\nexport { withSeed } from './webpack'\n\n// Types\n// Note: PublishUpload type is available from '../db/read/getPublishUploads'\n// Type-only exports cause issues with Rollup's parser. Import directly if needed:\n// import type { PublishUpload } from '@seedprotocol/sdk/db/read/getPublishUploads'\n\n// Client\nexport { client } from '../client'\n\n// All types\nexport * from '../types'\n\n// CLI exports\nexport { PathResolver } from './helpers/PathResolver'\nexport { BasePathResolver } from '../helpers/PathResolver/BasePathResolver'\nexport {\n commandExists,\n ensureNodeDbSchema,\n runSeedInit,\n findSeedBinary,\n} from './helpers/scripts'\nexport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '../helpers/constants'\n\n// Side effect imports for CLI — register platform services\nimport { createPlatformServices } from '../platform/index.node'\nimport { configurePlatform } from '../platform/configurePlatform'\nconfigurePlatform(createPlatformServices())\n\nenableMapSet() "],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,CACtC,QAAgB,KACc;IAC9B,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;;;IAI/C,MAAM,gBAAgB,GAAG,mCAAmC;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;IAE7C,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC;AAEhC,IAAA,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAwB;AACrE,QAAA,OAAO,WAAW;IACpB;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,CAAA,oCAAA,EAAuC,QAAQ,KAAK,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAE,CAC7G;IACH;AACF;AAEA;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAAkB,KAAsB;AACxE,IAAA,IAAI,CAAC,MAAM,CAAC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AI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC;KACrF;AAED,IAAA,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;AACnC,QAAA,IAAIA,WAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;AAC1B,YAAA,OAAO,OAAO;QAChB;IACF;AAEA,IAAA,OAAO,IAAI;AACb;AAEA;;;AAGG;AACI,MAAM,kBAAkB,GAAG,OAChC,cAAuB,EACvB,eAAwB,KACP;IACjB,IAAI,CAAC,eAAe,EAAE;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC;IAChE;AAEA,IAAA,MAAM,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;AACzC;AAEA;AACO,MAAM,WAAW,GAAG;;ACY3B,iBAAiB,CAAC,sBAAsB,EAAE,CAAC;AAE3C,YAAY,EAAE;;"}
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../src/imports/markdown.ts","../../src/node/webpack/index.ts","../../src/node/helpers/scripts.ts","../../src/node/index.ts"],"sourcesContent":["import yaml from 'js-yaml'\nimport { readFileSync } from 'fs'\nimport { Property, ModelPropertyDataTypes } from '@/Schema'\nimport { ModelDefinitions } from '@/types'\nimport { addModelsToDb } from '../helpers/db'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport type { Model } from '@/Model/Model'\n\n/**\n * Configuration structure expected in markdown frontmatter\n */\ntype SeedConfig = {\n seed: {\n model: string\n properties: {\n [propertyName: string]: {\n type: string\n target?: string\n /** For List: element type when primitive (e.g. 'Text', 'Number'). Use target for list of relations. */\n itemsType?: string\n }\n }\n }\n}\n\n/**\n * Parses markdown frontmatter from a file\n * @param filePath Path to the markdown file\n * @returns The parsed frontmatter as an object, or null if no frontmatter found\n */\nexport const parseMarkdownFrontmatter = (\n filePath: string,\n): Record<string, any> | null => {\n const content = readFileSync(filePath, 'utf-8')\n \n // Check for frontmatter delimiters (more flexible regex)\n // Matches --- at start, optional whitespace, content, ---, optional whitespace\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)\\n---(\\s*\\n|$)/\n const match = content.match(frontmatterRegex)\n \n if (!match) {\n return null\n }\n \n const frontmatterYaml = match[1]\n \n try {\n const frontmatter = yaml.load(frontmatterYaml) as Record<string, any>\n return frontmatter\n } catch (error) {\n throw new Error(\n `Failed to parse YAML frontmatter in ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Converts a seed config from frontmatter to ModelDefinitions format\n * @param config The seed configuration from frontmatter\n * @returns ModelDefinitions object ready to be saved to database\n */\nexport const processSeedConfig = (config: SeedConfig): ModelDefinitions => {\n if (!config.seed) {\n throw new Error('No seed configuration found in frontmatter')\n }\n \n const { model: modelName, properties: propertiesConfig } = config.seed\n \n if (!modelName) {\n throw new Error('Model name is required in seed configuration')\n }\n \n if (!propertiesConfig || Object.keys(propertiesConfig).length === 0) {\n throw new Error('Properties are required in seed configuration')\n }\n \n // Convert property configs to Property definitions\n const schema: Record<string, any> = {}\n \n for (const [propertyName, propertyConfig] of Object.entries(propertiesConfig)) {\n const { type, target, itemsType } = propertyConfig\n \n if (!type) {\n throw new Error(`Property type is required for ${propertyName}`)\n }\n \n // Map the type to Property constructor\n switch (type) {\n case ModelPropertyDataTypes.Text:\n schema[propertyName] = Property.Text()\n break\n case ModelPropertyDataTypes.Number:\n schema[propertyName] = Property.Number()\n break\n case ModelPropertyDataTypes.Boolean:\n schema[propertyName] = Property.Boolean()\n break\n case ModelPropertyDataTypes.Date:\n schema[propertyName] = Property.Date()\n break\n case ModelPropertyDataTypes.Image:\n schema[propertyName] = Property.Image()\n break\n case ModelPropertyDataTypes.Json:\n schema[propertyName] = Property.Json()\n break\n case ModelPropertyDataTypes.File:\n schema[propertyName] = Property.File()\n break\n case ModelPropertyDataTypes.Relation:\n if (!target) {\n throw new Error(\n `Target model is required for Relation property ${propertyName}`,\n )\n }\n schema[propertyName] = Property.Relation(target)\n break\n case ModelPropertyDataTypes.List:\n if (itemsType) {\n // List of primitives: itemsType = 'Text', 'Number', etc.\n if (itemsType === ModelPropertyDataTypes.Relation && target) {\n schema[propertyName] = Property.List('Relation', target)\n } else if (itemsType !== ModelPropertyDataTypes.Relation) {\n schema[propertyName] = Property.List(itemsType as any)\n } else {\n throw new Error(\n `List of relations requires target model for property ${propertyName}`,\n )\n }\n } else if (target) {\n // Backward compat: target = model name for list of relations\n schema[propertyName] = Property.List('Relation', target)\n } else {\n throw new Error(\n `List property ${propertyName} requires either itemsType (e.g. 'Text') or target (model name for list of relations)`,\n )\n }\n break\n default:\n throw new Error(\n `Unknown property type: ${type} for property ${propertyName}`,\n )\n }\n }\n \n // Create a mock ModelClass structure that matches ModelDefinitions\n // This is a simplified version that works with addModelsToInternalDb\n const modelClass = {\n schema,\n create: async () => {\n throw new Error('Model.create() should not be called directly')\n },\n originalConstructor: class {},\n }\n \n return {\n [modelName]: modelClass as any as Model,\n }\n}\n\n/**\n * Reads a markdown file, parses frontmatter, and saves models/properties to database\n * @param filePath Path to the markdown file\n * @param db Database instance (BetterSQLite3Database or SqliteRemoteDatabase)\n * @returns The created ModelDefinitions\n */\nexport const saveModelsFromMarkdown = async (\n filePath: string,\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n): Promise<ModelDefinitions> => {\n // Parse frontmatter\n const frontmatter = parseMarkdownFrontmatter(filePath)\n \n if (!frontmatter) {\n throw new Error(`No frontmatter found in ${filePath}`)\n }\n \n // Validate and process seed config\n const seedConfig = frontmatter as SeedConfig\n const modelDefinitions = processSeedConfig(seedConfig)\n \n // Save to database\n await addModelsToDb(modelDefinitions, undefined, undefined, undefined)\n \n return modelDefinitions\n}\n","/**\n * Webpack / Next.js config helper for Seed Protocol apps.\n */\nexport const withSeed = (config: any, webpack: any, isServer: boolean) => {\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/node:/, (resource: { request: string }) => {\n resource.request = resource.request.replace(/^node:/, '')\n }),\n )\n\n if (!isServer) {\n config.resolve.alias['fs'] = '@zenfs/core'\n config.resolve.alias['node:fs'] = '@zenfs/core'\n config.resolve.alias['node:path'] = 'path-browserify'\n config.resolve.alias['path'] = 'path-browserify'\n }\n\n if (isServer) {\n config.externals.push('@sqlite.org/sqlite-wasm')\n config.externals.push('chokidar')\n config.externals.push('arweave')\n }\n\n return config\n}\n","import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const commandExists = (command: string): boolean => {\n try {\n execSync(`which ${command}`, { stdio: 'ignore' })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Finds the seed binary path, trying multiple locations\n * @returns The path to the seed binary, or null if not found\n */\nexport const findSeedBinary = (): string | null => {\n const cwd = process.cwd()\n\n const possiblePaths = [\n path.join(cwd, 'node_modules', '.bin', 'seed'),\n path.join(cwd, 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n ]\n\n for (const binPath of possiblePaths) {\n if (fs.existsSync(binPath)) {\n return binPath\n }\n }\n\n return null\n}\n\n/**\n * Ensures the Node app DB exists and SDK migrations are applied.\n * (Formerly `runSeedInit`; CLI spawn / npx fallbacks archived under docs/archive/commented/.)\n */\nexport const ensureNodeDbSchema = async (\n _schemaFileDir?: string,\n appFilesDirPath?: string\n): Promise<void> => {\n if (!appFilesDirPath) {\n throw new Error('ensureNodeDbSchema requires appFilesDirPath')\n }\n\n await BaseDb.prepareDb(appFilesDirPath)\n}\n\n/** @deprecated Use ensureNodeDbSchema */\nexport const runSeedInit = ensureNodeDbSchema\n","import { enableMapSet } from 'immer'\n\n// Core schema exports\nexport {\n Model,\n Property,\n Image,\n List,\n Text,\n Json,\n Relation,\n Boolean,\n Number,\n Date,\n} from '../Schema'\n\n// Core classes\nexport { Item } from '../Item/Item'\nexport { ItemProperty, ItemPropertySaveValidationError } from '../ItemProperty/ItemProperty'\n\n// Node.js specific exports\nexport { FileManager } from './helpers/FileManager'\nexport { Db, resolveSdkDrizzleMigrationsDir } from './db/Db'\n\n// Schema exports\nexport { models, versions, seeds, metadata, appState, config, modelUids } from '../seedSchema'\n\n// Model access - use Model static methods instead\n// Models are accessible via Model.all(), Model.getById(), Model.getByName(), etc.\n\n// Helper exports\nexport { getCorrectId } from '../helpers'\nexport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '../helpers/relationSeedRef'\n\n// Import exports\nexport * from '../imports'\n\n// Event bus\nexport { eventEmitter } from '../eventBus'\n\n// Webpack helper\nexport { withSeed } from './webpack'\n\n// Types\n// Note: PublishUpload type is available from '../db/read/getPublishUploads'\n// Type-only exports cause issues with Rollup's parser. Import directly if needed:\n// import type { PublishUpload } from '@seedprotocol/sdk/db/read/getPublishUploads'\n\n// Client\nexport { client } from '../client'\n\n// All types\nexport * from '../types'\n\n// CLI exports\nexport { PathResolver } from './helpers/PathResolver'\nexport { BasePathResolver } from '../helpers/PathResolver/BasePathResolver'\nexport {\n commandExists,\n ensureNodeDbSchema,\n runSeedInit,\n findSeedBinary,\n} from './helpers/scripts'\nexport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '../helpers/constants'\n\n// Side effect imports for CLI — register platform services\nimport { createPlatformServices } from '../platform/index.node'\nimport { configurePlatform } from '../platform/configurePlatform'\nconfigurePlatform(createPlatformServices())\n\nenableMapSet() "],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;AA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;AAEA;AACO,MAAM,WAAW,GAAG;;ACiB3B,iBAAiB,CAAC,sBAAsB,EAAE,CAAC;AAE3C,YAAY,EAAE;;"}
|
package/dist/platform.browser.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { a as BaseDb, c as appState, t as BasePathResolver, B as BaseFileManager } from './BasePathResolver-
|
|
1
|
+
import { a as BaseDb, c as appState, t as BasePathResolver, B as BaseFileManager } from './BasePathResolver-B6CKqoKw.js';
|
|
2
2
|
import debug from 'debug';
|
|
3
|
-
import { sql } from 'drizzle-orm';
|
|
4
|
-
import { readMigrationFiles } from 'drizzle-orm/migrator';
|
|
5
3
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
5
|
+
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
6
|
+
import { sql } from 'drizzle-orm';
|
|
7
|
+
import './index-280bL-n4.js';
|
|
8
|
+
import { s as schema } from './index-Djd3667v.js';
|
|
9
9
|
import { SQLocalDrizzle } from 'sqlocal/drizzle';
|
|
10
10
|
import { Observable, distinctUntilChanged } from 'rxjs';
|
|
11
|
-
import { BaseArweaveClient, GET_TRANSACTION_TAGS } from '@seedprotocol/arweave';
|
|
11
|
+
import { BaseArweaveClient, getPreferredArweaveReadBaseUrls, fetchArweaveRawFromBaseUrl, GET_TRANSACTION_TAGS } from '@seedprotocol/arweave';
|
|
12
12
|
import { GraphQLClient } from 'graphql-request';
|
|
13
13
|
import Arweave from 'arweave';
|
|
14
|
-
import { BaseEasClient, BaseQueryClient } from '@seedprotocol/eas';
|
|
14
|
+
import { getEasEndpoint, BaseEasClient, BaseQueryClient } from '@seedprotocol/eas';
|
|
15
15
|
import { QueryClient } from '@tanstack/react-query';
|
|
16
16
|
import 'drizzle-orm/sqlite-core';
|
|
17
17
|
import 'xstate';
|
|
18
18
|
import 'pluralize';
|
|
19
|
+
import './db-WbrzEf7c.js';
|
|
20
|
+
import 'drizzle-orm/casing';
|
|
21
|
+
import 'lodash-es';
|
|
19
22
|
import '@sinclair/typebox';
|
|
20
23
|
import 'nanoid';
|
|
21
24
|
import 'nanoid-dictionary';
|
|
@@ -199,29 +202,58 @@ var filesDownload = `(
|
|
|
199
202
|
const root = filesRoot.replace(/\/$/, '');
|
|
200
203
|
return [root, ...parts].filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
201
204
|
};
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
const toBaseUrl = (hostOrUrl) => {
|
|
206
|
+
const h = (hostOrUrl || '').trim().replace(/\/$/, '');
|
|
207
|
+
if (!h)
|
|
208
|
+
return '';
|
|
209
|
+
if (h.startsWith('http://') || h.startsWith('https://'))
|
|
210
|
+
return h;
|
|
211
|
+
const protocol = h.startsWith('127.0.0.1') || h.startsWith('localhost') || h.includes(':1984')
|
|
212
|
+
? 'http'
|
|
213
|
+
: 'https';
|
|
214
|
+
return `${protocol}://${h}`;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* GET /raw/{id} from each gateway in order. `networkFailedEverywhere` is true only when no gateway
|
|
218
|
+
* answered at all; a non-2xx (e.g. not yet propagated) is not a reason to exclude the transaction.
|
|
219
|
+
*/
|
|
220
|
+
const fetchRaw = async (baseUrls, transactionId) => {
|
|
221
|
+
let answered = false;
|
|
222
|
+
for (const base of baseUrls) {
|
|
205
223
|
try {
|
|
206
|
-
const response = await fetch(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return `${protocol}://${h}`;
|
|
215
|
-
})();
|
|
216
|
-
return `${base}/raw/${transactionId}`;
|
|
217
|
-
})());
|
|
218
|
-
arrayBuffer = await response.arrayBuffer();
|
|
224
|
+
const response = await fetch(`${base}/raw/${transactionId}`);
|
|
225
|
+
answered = true;
|
|
226
|
+
if (!response.ok)
|
|
227
|
+
continue;
|
|
228
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
229
|
+
if (arrayBuffer.byteLength > 0) {
|
|
230
|
+
return { arrayBuffer, networkFailedEverywhere: false };
|
|
231
|
+
}
|
|
219
232
|
}
|
|
220
233
|
catch (error) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
234
|
+
/* next gateway */
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return { networkFailedEverywhere: !answered };
|
|
238
|
+
};
|
|
239
|
+
const downloadFiles = async ({ transactionIds, arweaveHost, arweaveBaseUrls, filesRoot = '/files', }) => {
|
|
240
|
+
// Preferred / resolved gateways first, then the configured host; deduped.
|
|
241
|
+
const baseUrls = [];
|
|
242
|
+
for (const candidate of (arweaveBaseUrls || []).concat([arweaveHost])) {
|
|
243
|
+
const base = toBaseUrl(candidate);
|
|
244
|
+
if (base && baseUrls.indexOf(base) === -1) {
|
|
245
|
+
baseUrls.push(base);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
for (const transactionId of transactionIds) {
|
|
249
|
+
const { arrayBuffer, networkFailedEverywhere } = await fetchRaw(baseUrls, transactionId);
|
|
250
|
+
if (!arrayBuffer) {
|
|
251
|
+
if (networkFailedEverywhere) {
|
|
252
|
+
globalThis.postMessage({
|
|
253
|
+
message: 'excludeTransaction',
|
|
254
|
+
transactionId,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
225
257
|
continue;
|
|
226
258
|
}
|
|
227
259
|
let dataString;
|
|
@@ -277,6 +309,9 @@ var filesDownload = `(
|
|
|
277
309
|
let buffer;
|
|
278
310
|
try {
|
|
279
311
|
const response = await fetch(url);
|
|
312
|
+
if (!response.ok) {
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
280
315
|
buffer = await response.arrayBuffer();
|
|
281
316
|
}
|
|
282
317
|
catch (error) {
|
|
@@ -351,7 +386,7 @@ const logger$5 = debug('seedSdk:browser:workers:FileDownloader');
|
|
|
351
386
|
class FileDownloader {
|
|
352
387
|
constructor() {
|
|
353
388
|
this.workersArchive = [];
|
|
354
|
-
this.downloadAll = async ({ transactionIds, arweaveHost, excludedTransactions }) => {
|
|
389
|
+
this.downloadAll = async ({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions }) => {
|
|
355
390
|
if (this.workersArchive.length > 0) {
|
|
356
391
|
for (let i = 0; i < this.workersArchive.length; i++) {
|
|
357
392
|
this.workersArchive[i].terminate();
|
|
@@ -384,6 +419,7 @@ class FileDownloader {
|
|
|
384
419
|
worker.postMessage({
|
|
385
420
|
transactionIds,
|
|
386
421
|
arweaveHost,
|
|
422
|
+
arweaveBaseUrls,
|
|
387
423
|
debug: logger$5.enabled,
|
|
388
424
|
filesRoot: BaseFileManager.getWorkingDir(),
|
|
389
425
|
});
|
|
@@ -1014,9 +1050,9 @@ class BrowserFileManager {
|
|
|
1014
1050
|
await configureRoot();
|
|
1015
1051
|
}
|
|
1016
1052
|
}
|
|
1017
|
-
async downloadAllFiles({ transactionIds, arweaveHost, excludedTransactions, }) {
|
|
1053
|
+
async downloadAllFiles({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions, }) {
|
|
1018
1054
|
const fileDownloader = new FileDownloader();
|
|
1019
|
-
await fileDownloader.downloadAll({ transactionIds, arweaveHost, excludedTransactions });
|
|
1055
|
+
await fileDownloader.downloadAll({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions });
|
|
1020
1056
|
}
|
|
1021
1057
|
async resizeImage({ filePath, width, height }) {
|
|
1022
1058
|
const imageResizer = new ImageResizer();
|
|
@@ -1650,6 +1686,8 @@ const migrationSql_0013_eas_sync_processes = `CREATE TABLE \`eas_sync_processes\
|
|
|
1650
1686
|
\`updated_at\` integer
|
|
1651
1687
|
);
|
|
1652
1688
|
`;
|
|
1689
|
+
const migrationSql_0014_add_error_code_to_publish_processes = `ALTER TABLE \`publish_processes\` ADD \`error_code\` text;
|
|
1690
|
+
`;
|
|
1653
1691
|
// Journal JSON file
|
|
1654
1692
|
const journalJson = `{
|
|
1655
1693
|
"version": "7",
|
|
@@ -1752,6 +1790,13 @@ const journalJson = `{
|
|
|
1752
1790
|
"when": 1774300000000,
|
|
1753
1791
|
"tag": "0013_eas_sync_processes",
|
|
1754
1792
|
"breakpoints": true
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
"idx": 14,
|
|
1796
|
+
"version": "6",
|
|
1797
|
+
"when": 1774400000000,
|
|
1798
|
+
"tag": "0014_add_error_code_to_publish_processes",
|
|
1799
|
+
"breakpoints": true
|
|
1755
1800
|
}
|
|
1756
1801
|
]
|
|
1757
1802
|
}`;
|
|
@@ -1760,8 +1805,8 @@ const journalJson = `{
|
|
|
1760
1805
|
const snapshotJson = `{
|
|
1761
1806
|
"version": "6",
|
|
1762
1807
|
"dialect": "sqlite",
|
|
1763
|
-
"id": "
|
|
1764
|
-
"prevId": "
|
|
1808
|
+
"id": "14e73eef-092a-4310-a86f-2f815470bdce",
|
|
1809
|
+
"prevId": "a9e8f7d6-c5b4-4321-a0b9-c8d7e6f5a4b3",
|
|
1765
1810
|
"tables": {
|
|
1766
1811
|
"appState": {
|
|
1767
1812
|
"name": "appState",
|
|
@@ -2453,6 +2498,13 @@ const snapshotJson = `{
|
|
|
2453
2498
|
"notNull": false,
|
|
2454
2499
|
"autoincrement": false
|
|
2455
2500
|
},
|
|
2501
|
+
"error_code": {
|
|
2502
|
+
"name": "error_code",
|
|
2503
|
+
"type": "text",
|
|
2504
|
+
"primaryKey": false,
|
|
2505
|
+
"notNull": false,
|
|
2506
|
+
"autoincrement": false
|
|
2507
|
+
},
|
|
2456
2508
|
"persisted_snapshot": {
|
|
2457
2509
|
"name": "persisted_snapshot",
|
|
2458
2510
|
"type": "text",
|
|
@@ -3037,9 +3089,56 @@ var drizzleFiles = /*#__PURE__*/Object.freeze({
|
|
|
3037
3089
|
migrationSql_0011_normalize_placeholder_uids: migrationSql_0011_normalize_placeholder_uids,
|
|
3038
3090
|
migrationSql_0012_html_embedded_image_co_publish: migrationSql_0012_html_embedded_image_co_publish,
|
|
3039
3091
|
migrationSql_0013_eas_sync_processes: migrationSql_0013_eas_sync_processes,
|
|
3092
|
+
migrationSql_0014_add_error_code_to_publish_processes: migrationSql_0014_add_error_code_to_publish_processes,
|
|
3040
3093
|
snapshotJson: snapshotJson
|
|
3041
3094
|
});
|
|
3042
3095
|
|
|
3096
|
+
/**
|
|
3097
|
+
* Build drizzle migration metadata from embedded SQL strings.
|
|
3098
|
+
* Avoids `drizzle-orm/migrator` (Node fs / path / crypto) on the browser graph.
|
|
3099
|
+
*/
|
|
3100
|
+
function getEmbeddedMigrations() {
|
|
3101
|
+
const journal = JSON.parse(journalJson);
|
|
3102
|
+
const entries = journal.entries ?? [];
|
|
3103
|
+
return entries.map((entry) => {
|
|
3104
|
+
const varName = `migrationSql_${entry.tag}`;
|
|
3105
|
+
const query = drizzleFiles[varName];
|
|
3106
|
+
if (typeof query !== 'string') {
|
|
3107
|
+
throw new Error(`No embedded migration content for ${entry.tag}`);
|
|
3108
|
+
}
|
|
3109
|
+
const trimmed = query.trim();
|
|
3110
|
+
return {
|
|
3111
|
+
sql: trimmed.split('--> statement-breakpoint'),
|
|
3112
|
+
bps: Boolean(entry.breakpoints),
|
|
3113
|
+
folderMillis: entry.when,
|
|
3114
|
+
hash: bytesToHex(sha256(utf8ToBytes(trimmed))),
|
|
3115
|
+
};
|
|
3116
|
+
});
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Same apply loop as drizzle-orm/sqlite-proxy/migrator, with in-memory migrations.
|
|
3120
|
+
*/
|
|
3121
|
+
async function applyEmbeddedMigrations(db, migrations, migrationsTable = '__drizzle_migrations') {
|
|
3122
|
+
await db.run(sql `
|
|
3123
|
+
CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (
|
|
3124
|
+
id SERIAL PRIMARY KEY,
|
|
3125
|
+
hash text NOT NULL,
|
|
3126
|
+
created_at numeric
|
|
3127
|
+
)
|
|
3128
|
+
`);
|
|
3129
|
+
const dbMigrations = await db.values(sql `SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`);
|
|
3130
|
+
const lastDbMigration = dbMigrations[0] ?? undefined;
|
|
3131
|
+
const queriesToRun = [];
|
|
3132
|
+
for (const migration of migrations) {
|
|
3133
|
+
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
3134
|
+
queriesToRun.push(...migration.sql, `INSERT INTO \`${migrationsTable}\` ("hash", "created_at") VALUES('${migration.hash}', '${migration.folderMillis}')`);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
for (const query of queriesToRun) {
|
|
3138
|
+
await db.run(sql.raw(query));
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3043
3142
|
const logger$2 = debug('seedSdk:browser:db:createSqlocalDrizzle');
|
|
3044
3143
|
/** First sqlocal work can include sqlite-wasm fetch; keep this long to avoid false positives. */
|
|
3045
3144
|
const SQLOCAL_FIRST_QUERY_TIMEOUT_MS = 90000;
|
|
@@ -3185,7 +3284,7 @@ class BrowserDb {
|
|
|
3185
3284
|
await raceSqlocalStartup((async () => {
|
|
3186
3285
|
await this.runMigrations(db);
|
|
3187
3286
|
this.appDb = db;
|
|
3188
|
-
const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-
|
|
3287
|
+
const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-CBsf7LnU.js');
|
|
3189
3288
|
await backfillMetadataPropertyIds();
|
|
3190
3289
|
})(), workerFailed);
|
|
3191
3290
|
return this.appDb;
|
|
@@ -3308,23 +3407,11 @@ class BrowserDb {
|
|
|
3308
3407
|
}
|
|
3309
3408
|
}
|
|
3310
3409
|
/** Internal migration runner. Used by prepareDb before appDb is set. */
|
|
3311
|
-
async runMigrations(db,
|
|
3312
|
-
const migrationsFolder = pathToDbDir ?? `${this.filesDir}/db`;
|
|
3410
|
+
async runMigrations(db, _pathToDbDir) {
|
|
3313
3411
|
try {
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
});
|
|
3318
|
-
logger$1('[Db.runMigrations] migrations', migrations);
|
|
3319
|
-
await migrate(db, async (queriesToRun) => {
|
|
3320
|
-
logger$1('queriesToRun', queriesToRun);
|
|
3321
|
-
for (const query of queriesToRun) {
|
|
3322
|
-
logger$1('query', query);
|
|
3323
|
-
await db.run(sql.raw(query));
|
|
3324
|
-
}
|
|
3325
|
-
}, {
|
|
3326
|
-
migrationsFolder,
|
|
3327
|
-
});
|
|
3412
|
+
const migrations = getEmbeddedMigrations();
|
|
3413
|
+
logger$1('[Db.runMigrations] embedded migrations', migrations.length);
|
|
3414
|
+
await applyEmbeddedMigrations(db, migrations);
|
|
3328
3415
|
logger$1('[Db.runMigrations] migrations completed');
|
|
3329
3416
|
}
|
|
3330
3417
|
catch (error) {
|
|
@@ -3408,20 +3495,13 @@ const getArweaveInstance = () => {
|
|
|
3408
3495
|
return _arweaveInstance;
|
|
3409
3496
|
}
|
|
3410
3497
|
_arweaveGatewayKey = gatewayKey;
|
|
3411
|
-
const
|
|
3412
|
-
const protocol = BaseArweaveClient.getProtocol();
|
|
3498
|
+
const apiConfig = BaseArweaveClient.getArweaveJsApiConfig();
|
|
3413
3499
|
// Handle both ES modules and CommonJS exports from arweave package
|
|
3414
3500
|
if ("default" in Arweave && typeof Arweave.default?.init === "function") {
|
|
3415
|
-
_arweaveInstance = Arweave.default.init(
|
|
3416
|
-
host,
|
|
3417
|
-
protocol,
|
|
3418
|
-
});
|
|
3501
|
+
_arweaveInstance = Arweave.default.init(apiConfig);
|
|
3419
3502
|
}
|
|
3420
3503
|
else {
|
|
3421
|
-
_arweaveInstance = Arweave.init(
|
|
3422
|
-
host,
|
|
3423
|
-
protocol,
|
|
3424
|
-
});
|
|
3504
|
+
_arweaveInstance = Arweave.init(apiConfig);
|
|
3425
3505
|
}
|
|
3426
3506
|
return _arweaveInstance;
|
|
3427
3507
|
};
|
|
@@ -3462,6 +3542,23 @@ class BrowserArweaveClient {
|
|
|
3462
3542
|
}
|
|
3463
3543
|
}
|
|
3464
3544
|
async getTransactionData(transactionId, options) {
|
|
3545
|
+
// Preferred gateways (usually the one the item was uploaded through) serve it before L1 does.
|
|
3546
|
+
// `/raw` is already decoded, so skip them when the caller asked for undecoded data.
|
|
3547
|
+
const preferred = options?.decode === false ? [] : getPreferredArweaveReadBaseUrls();
|
|
3548
|
+
for (const base of preferred) {
|
|
3549
|
+
const response = await fetchArweaveRawFromBaseUrl(base, transactionId);
|
|
3550
|
+
if (!response)
|
|
3551
|
+
continue;
|
|
3552
|
+
try {
|
|
3553
|
+
if (options?.string) {
|
|
3554
|
+
return await response.text();
|
|
3555
|
+
}
|
|
3556
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
3557
|
+
}
|
|
3558
|
+
catch (error) {
|
|
3559
|
+
logger("Error reading preferred gateway response:", error);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3465
3562
|
// Path-prefixed proxies (app-server Hyper proxy) are not supported by arweave.init host;
|
|
3466
3563
|
// fetch via getRawUrl so /api/seed-gateway/... works.
|
|
3467
3564
|
if (BaseArweaveClient.getGatewayPath()) {
|
|
@@ -3574,11 +3671,13 @@ class BrowserArweaveClient {
|
|
|
3574
3671
|
BaseArweaveClient.configure(new BrowserArweaveClient());
|
|
3575
3672
|
|
|
3576
3673
|
class BrowserEasClient {
|
|
3674
|
+
/** Reads the endpoint per call so SDK / publish chain config applied after import takes effect. */
|
|
3577
3675
|
getEasClient() {
|
|
3578
|
-
|
|
3579
|
-
|
|
3676
|
+
const url = getEasEndpoint();
|
|
3677
|
+
if (this.easClient?.url !== url) {
|
|
3678
|
+
this.easClient = { url, client: new GraphQLClient(url) };
|
|
3580
3679
|
}
|
|
3581
|
-
return this.easClient;
|
|
3680
|
+
return this.easClient.client;
|
|
3582
3681
|
}
|
|
3583
3682
|
}
|
|
3584
3683
|
BaseEasClient.configure(new BrowserEasClient());
|