@seedprotocol/sdk 0.7.3-next.613.g79a8dfd → 0.7.4-next.711.gce2b766
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/{db-CQt-gcAl.js → BasePathResolver-Cm4apKRb.js} +2041 -127
- package/dist/BasePathResolver-Cm4apKRb.js.map +1 -0
- package/dist/{ClientManager-DDA9956Y.js → ClientManager-i3nJASkg.js} +664 -277
- package/dist/ClientManager-i3nJASkg.js.map +1 -0
- package/dist/{Item-D4FigtYS.js → Item-DBFchXpC.js} +495 -219
- package/dist/Item-DBFchXpC.js.map +1 -0
- package/dist/{ModelProperty-BDt6AU2h.js → ModelProperty-BS49g01Y.js} +167 -47
- package/dist/ModelProperty-BS49g01Y.js.map +1 -0
- package/dist/{Schema-B8xqLWkL.js → Schema-CpMNEnUO.js} +53 -42
- package/dist/Schema-CpMNEnUO.js.map +1 -0
- package/dist/{SchemaValidationService-BPxkfDLU.js → SchemaValidationService-DieV4KL-.js} +13 -14
- package/dist/{SchemaValidationService-BPxkfDLU.js.map → SchemaValidationService-DieV4KL-.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DuTPcv8t.js → backfillMetadataPropertyIds-DSoOoTnX.js} +14 -7
- package/dist/{backfillMetadataPropertyIds-DuTPcv8t.js.map → backfillMetadataPropertyIds-DSoOoTnX.js.map} +1 -1
- package/dist/{configurePlatform-YcOiDQBZ.js → configurePlatform-D0lQGAMQ.js} +8 -7
- package/dist/{configurePlatform-YcOiDQBZ.js.map → configurePlatform-D0lQGAMQ.js.map} +1 -1
- package/dist/detachRowsBeforeDelete-S0q-DJPT.js +50 -0
- package/dist/detachRowsBeforeDelete-S0q-DJPT.js.map +1 -0
- package/dist/{eas-CpOD74Ke.js → eas-6pjU-OuX.js} +9 -8
- package/dist/eas-6pjU-OuX.js.map +1 -0
- package/dist/{getItem-B_OoFkd7.js → getItem-CxBNZ-WL.js} +13 -11
- package/dist/{getItem-B_OoFkd7.js.map → getItem-CxBNZ-WL.js.map} +1 -1
- package/dist/{getPublishPayload-Xl3sRkR-.js → getPublishPayload-CTCvRUoU.js} +50 -18
- package/dist/getPublishPayload-CTCvRUoU.js.map +1 -0
- package/dist/getPublishUploads-SFHCbf_y.js +648 -0
- package/dist/getPublishUploads-SFHCbf_y.js.map +1 -0
- package/dist/{index-Xl1_4Lmb.js → index-8O3Uow-Y.js} +125 -57
- package/dist/index-8O3Uow-Y.js.map +1 -0
- package/dist/{index-CSOQFAOn.js → index-AVFTVp1m.js} +2 -2
- package/dist/index-AVFTVp1m.js.map +1 -0
- package/dist/index-Cvt5UBz4.js +30 -0
- package/dist/index-Cvt5UBz4.js.map +1 -0
- package/dist/{index.browser-CjTe0vt1.js → index.browser-DBhxRoe8.js} +554 -165
- package/dist/index.browser-DBhxRoe8.js.map +1 -0
- package/dist/{index.node-Cfa7npS6.js → index.node-CJhlcNHM.js} +25 -13
- package/dist/index.node-CJhlcNHM.js.map +1 -0
- package/dist/main.js +30 -47
- package/dist/main.js.map +1 -1
- package/dist/mimeTypes-DHAHC4eZ.js +204 -0
- package/dist/mimeTypes-DHAHC4eZ.js.map +1 -0
- package/dist/node.js +19 -21
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +13 -11
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +18 -5
- package/dist/platform.node.js.map +1 -1
- package/dist/{property-BrXkY1Rg.js → property-DwPD283A.js} +14 -12
- package/dist/property-DwPD283A.js.map +1 -0
- package/dist/{publishDraftGraph-X0Wr9txE.js → publishDraftGraph-BOn3_Occ.js} +6 -9
- package/dist/{publishDraftGraph-X0Wr9txE.js.map → publishDraftGraph-BOn3_Occ.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js → resetAmbiguousLegacyItemData-BkYmBeJc.js} +14 -3
- package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js.map → resetAmbiguousLegacyItemData-BkYmBeJc.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DFVdnYq8.js → resolveModelForSyncedSeed-BL24nLa7.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DFVdnYq8.js.map → resolveModelForSyncedSeed-BL24nLa7.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +21 -3
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/runPublish.d.ts +11 -2
- package/dist/src/Item/service/actors/runPublish.d.ts.map +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts +12 -2
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +5 -3
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +10 -4
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/index.d.ts +2 -2
- package/dist/src/ModelProperty/ModelProperty.d.ts +10 -2
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +3 -0
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +2 -2
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/index.d.ts +0 -1
- package/dist/src/Schema/index.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +4 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/helpers/tolerantWebAccess.d.ts +79 -4
- package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +19 -4
- 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 +30 -11
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +6 -0
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts +13 -6
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/db/migrateLegacyItemStorageRows.d.ts +57 -0
- package/dist/src/db/migrateLegacyItemStorageRows.d.ts.map +1 -0
- package/dist/src/db/read/getCompositeChildPaths.d.ts +13 -0
- package/dist/src/db/read/getCompositeChildPaths.d.ts.map +1 -0
- package/dist/src/db/read/getItems.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +32 -3
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +2 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
- package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts +44 -0
- package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts.map +1 -0
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/eventBus.d.ts +5 -0
- package/dist/src/eventBus.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +3 -3
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +25 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/arweaveContentTags.d.ts +33 -0
- package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -0
- package/dist/src/helpers/cachedPropertyRefresh.d.ts +12 -0
- package/dist/src/helpers/cachedPropertyRefresh.d.ts.map +1 -0
- package/dist/src/helpers/compositeUpload.d.ts +28 -0
- package/dist/src/helpers/compositeUpload.d.ts.map +1 -0
- package/dist/src/helpers/db.d.ts +3 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/easSdk.d.ts +16 -0
- package/dist/src/helpers/easSdk.d.ts.map +1 -0
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts +16 -0
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityDestroy.d.ts +2 -0
- package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
- package/dist/src/helpers/itemStorageFile.d.ts +57 -0
- package/dist/src/helpers/itemStorageFile.d.ts.map +1 -0
- package/dist/src/helpers/mapWithConcurrency.d.ts +7 -0
- package/dist/src/helpers/mapWithConcurrency.d.ts.map +1 -0
- package/dist/src/helpers/mimeTypes.d.ts +43 -0
- package/dist/src/helpers/mimeTypes.d.ts.map +1 -0
- package/dist/src/helpers/ownership.d.ts +28 -4
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/property/index.d.ts +37 -51
- package/dist/src/helpers/property/index.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +27 -8
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/helpers/storageDir.d.ts +16 -0
- package/dist/src/helpers/storageDir.d.ts.map +1 -0
- package/dist/src/helpers/tabCoordinator.d.ts +5 -1
- package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
- package/dist/src/helpers/tabEvents.d.ts +23 -2
- package/dist/src/helpers/tabEvents.d.ts.map +1 -1
- package/dist/src/helpers/updateSchema.d.ts +5 -0
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/helpers/waitForEntityIdle.d.ts +5 -0
- package/dist/src/helpers/waitForEntityIdle.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts +9 -0
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +7 -1
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/helpers/PathResolver.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +8 -1
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/platform/index.browser.d.ts +2 -0
- package/dist/src/platform/index.browser.d.ts.map +1 -1
- package/dist/src/platform/index.node.d.ts +2 -0
- package/dist/src/platform/index.node.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts +3 -14
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +12 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/machines.d.ts +2 -0
- package/dist/src/types/machines.d.ts.map +1 -1
- package/dist/src/types/property.d.ts +8 -0
- package/dist/src/types/property.d.ts.map +1 -1
- package/dist/src/types/publish.d.ts +14 -0
- package/dist/src/types/publish.d.ts.map +1 -1
- package/dist/{syncDbWithEas-BU-jZ5bJ.js → syncDbWithEas-Bv2Fe38J.js} +17 -17
- package/dist/{syncDbWithEas-BU-jZ5bJ.js.map → syncDbWithEas-Bv2Fe38J.js.map} +1 -1
- package/dist/tabEvents-9s2WCYw-.js +335 -0
- package/dist/tabEvents-9s2WCYw-.js.map +1 -0
- package/dist/tolerantWebAccess-iUu80pAP.js +551 -0
- package/dist/tolerantWebAccess-iUu80pAP.js.map +1 -0
- package/dist/{updateSeedRevokedAt-iLpzae1i.js → updateSeedRevokedAt-zBfi931j.js} +3 -3
- package/dist/{updateSeedRevokedAt-iLpzae1i.js.map → updateSeedRevokedAt-zBfi931j.js.map} +1 -1
- package/package.json +11 -12
- package/src/node/easLodashRegister.js +4 -0
- package/dist/BasePathResolver-BdxCSIzn.js +0 -679
- package/dist/BasePathResolver-BdxCSIzn.js.map +0 -1
- package/dist/ClientManager-DDA9956Y.js.map +0 -1
- package/dist/Item-D4FigtYS.js.map +0 -1
- package/dist/ModelProperty-BDt6AU2h.js.map +0 -1
- package/dist/Schema-B8xqLWkL.js.map +0 -1
- package/dist/cjs/ModelProperty-B-cZm1yU.js +0 -1977
- package/dist/cjs/ModelProperty-B-cZm1yU.js.map +0 -1
- package/dist/cjs/Schema-STP972Xw.js +0 -5256
- package/dist/cjs/Schema-STP972Xw.js.map +0 -1
- package/dist/cjs/SchemaValidationService-CKNW1bKg.js +0 -778
- package/dist/cjs/SchemaValidationService-CKNW1bKg.js.map +0 -1
- package/dist/cjs/backfillMetadataPropertyIds-CP3y1skt.js +0 -89
- package/dist/cjs/backfillMetadataPropertyIds-CP3y1skt.js.map +0 -1
- package/dist/cjs/eas-CAnUC4wd.js +0 -138
- package/dist/cjs/eas-CAnUC4wd.js.map +0 -1
- package/dist/cjs/getItem-CWgb3e9G.js +0 -58
- package/dist/cjs/getItem-CWgb3e9G.js.map +0 -1
- package/dist/cjs/getPublishPayload-BsZWiJ03.js +0 -1603
- package/dist/cjs/getPublishPayload-BsZWiJ03.js.map +0 -1
- package/dist/cjs/getPublishUploads-BQr8aMVP.js +0 -495
- package/dist/cjs/getPublishUploads-BQr8aMVP.js.map +0 -1
- package/dist/cjs/index-nA5PxBSs.js +0 -70
- package/dist/cjs/index-nA5PxBSs.js.map +0 -1
- package/dist/cjs/index-usKaANAq.js +0 -22171
- package/dist/cjs/index-usKaANAq.js.map +0 -1
- package/dist/cjs/index.browser-BSf8HpnU.js +0 -22
- package/dist/cjs/index.browser-BSf8HpnU.js.map +0 -1
- package/dist/cjs/property-xMwPhQ5N.js +0 -327
- package/dist/cjs/property-xMwPhQ5N.js.map +0 -1
- package/dist/cjs/publishDraftGraph-BRWlR1KO.js +0 -403
- package/dist/cjs/publishDraftGraph-BRWlR1KO.js.map +0 -1
- package/dist/cjs/resetAmbiguousLegacyItemData-8nfkj9rz.js +0 -116
- package/dist/cjs/resetAmbiguousLegacyItemData-8nfkj9rz.js.map +0 -1
- package/dist/cjs/resolveModelForSyncedSeed-kYRuDWYw.js +0 -49
- package/dist/cjs/resolveModelForSyncedSeed-kYRuDWYw.js.map +0 -1
- package/dist/cjs/syncDbWithEas-DqRhV8o2.js +0 -886
- package/dist/cjs/syncDbWithEas-DqRhV8o2.js.map +0 -1
- package/dist/db-CQt-gcAl.js.map +0 -1
- package/dist/eas-CpOD74Ke.js.map +0 -1
- package/dist/getPublishPayload-Xl3sRkR-.js.map +0 -1
- package/dist/getPublishUploads-DHP01KgU.js +0 -484
- package/dist/getPublishUploads-DHP01KgU.js.map +0 -1
- package/dist/index-BGt4_oPO.js +0 -31
- package/dist/index-BGt4_oPO.js.map +0 -1
- package/dist/index-CSOQFAOn.js.map +0 -1
- package/dist/index-Xl1_4Lmb.js.map +0 -1
- package/dist/index.browser-CjTe0vt1.js.map +0 -1
- package/dist/index.node-Cfa7npS6.js.map +0 -1
- package/dist/main.cjs +0 -84
- package/dist/main.cjs.map +0 -1
- package/dist/property-BrXkY1Rg.js.map +0 -1
- package/dist/tabEvents-BZJMY5uK.js +0 -1344
- package/dist/tabEvents-BZJMY5uK.js.map +0 -1
- package/dist/tolerantWebAccess-BZ2RA_mb.js +0 -160
- package/dist/tolerantWebAccess-BZ2RA_mb.js.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File extension <-> MIME type, shared by the upload side (`getPublishUploads.ts`, which sets the
|
|
3
|
+
* `Content-Type` tag) and the download worker (`browser/workers/filesDownload.ts`, which picks the
|
|
4
|
+
* extension of a file saved under `files/`). The worker runs from a string and cannot import this
|
|
5
|
+
* module, so {@link MIME_TO_EXTENSION} is injected into its source as JSON.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Lowercase extension (no dot) to MIME type. Includes the odd extensions the SDK itself produces:
|
|
9
|
+
* `saveImage` names a file `<id>.<subtype>` (e.g. `.svg+xml`, `.x-icon`), so subtypes appear here too.
|
|
10
|
+
*/
|
|
11
|
+
const EXTENSION_TO_MIME = {
|
|
12
|
+
// images
|
|
13
|
+
png: 'image/png',
|
|
14
|
+
apng: 'image/apng',
|
|
15
|
+
jpg: 'image/jpeg',
|
|
16
|
+
jpeg: 'image/jpeg',
|
|
17
|
+
jfif: 'image/jpeg',
|
|
18
|
+
gif: 'image/gif',
|
|
19
|
+
webp: 'image/webp',
|
|
20
|
+
avif: 'image/avif',
|
|
21
|
+
heic: 'image/heic',
|
|
22
|
+
heif: 'image/heif',
|
|
23
|
+
svg: 'image/svg+xml',
|
|
24
|
+
'svg+xml': 'image/svg+xml',
|
|
25
|
+
bmp: 'image/bmp',
|
|
26
|
+
ico: 'image/x-icon',
|
|
27
|
+
'x-icon': 'image/x-icon',
|
|
28
|
+
'vnd.microsoft.icon': 'image/x-icon',
|
|
29
|
+
tif: 'image/tiff',
|
|
30
|
+
tiff: 'image/tiff',
|
|
31
|
+
// text / documents
|
|
32
|
+
html: 'text/html',
|
|
33
|
+
htm: 'text/html',
|
|
34
|
+
xhtml: 'application/xhtml+xml',
|
|
35
|
+
json: 'application/json',
|
|
36
|
+
txt: 'text/plain',
|
|
37
|
+
plain: 'text/plain',
|
|
38
|
+
md: 'text/markdown',
|
|
39
|
+
markdown: 'text/markdown',
|
|
40
|
+
csv: 'text/csv',
|
|
41
|
+
tsv: 'text/tab-separated-values',
|
|
42
|
+
xml: 'application/xml',
|
|
43
|
+
css: 'text/css',
|
|
44
|
+
js: 'text/javascript',
|
|
45
|
+
mjs: 'text/javascript',
|
|
46
|
+
pdf: 'application/pdf',
|
|
47
|
+
rtf: 'application/rtf',
|
|
48
|
+
epub: 'application/epub+zip',
|
|
49
|
+
zip: 'application/zip',
|
|
50
|
+
gz: 'application/gzip',
|
|
51
|
+
doc: 'application/msword',
|
|
52
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
53
|
+
xls: 'application/vnd.ms-excel',
|
|
54
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
55
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
56
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
57
|
+
odt: 'application/vnd.oasis.opendocument.text',
|
|
58
|
+
// audio
|
|
59
|
+
mp3: 'audio/mpeg',
|
|
60
|
+
mpeg: 'audio/mpeg',
|
|
61
|
+
wav: 'audio/wav',
|
|
62
|
+
ogg: 'audio/ogg',
|
|
63
|
+
oga: 'audio/ogg',
|
|
64
|
+
opus: 'audio/opus',
|
|
65
|
+
m4a: 'audio/mp4',
|
|
66
|
+
aac: 'audio/aac',
|
|
67
|
+
flac: 'audio/flac',
|
|
68
|
+
weba: 'audio/webm',
|
|
69
|
+
// video
|
|
70
|
+
mp4: 'video/mp4',
|
|
71
|
+
m4v: 'video/mp4',
|
|
72
|
+
webm: 'video/webm',
|
|
73
|
+
mov: 'video/quicktime',
|
|
74
|
+
quicktime: 'video/quicktime',
|
|
75
|
+
ogv: 'video/ogg',
|
|
76
|
+
mkv: 'video/x-matroska',
|
|
77
|
+
avi: 'video/x-msvideo',
|
|
78
|
+
// fonts
|
|
79
|
+
woff: 'font/woff',
|
|
80
|
+
woff2: 'font/woff2',
|
|
81
|
+
ttf: 'font/ttf',
|
|
82
|
+
otf: 'font/otf',
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* MIME type to the extension a downloaded file gets. One canonical extension per type (the
|
|
86
|
+
* first one listed here wins over {@link EXTENSION_TO_MIME}'s aliases), plus a few common
|
|
87
|
+
* non-canonical spellings a gateway may send.
|
|
88
|
+
*/
|
|
89
|
+
const MIME_TO_EXTENSION = (() => {
|
|
90
|
+
const preferred = {
|
|
91
|
+
'image/jpeg': 'jpg',
|
|
92
|
+
'image/svg+xml': 'svg',
|
|
93
|
+
'image/x-icon': 'ico',
|
|
94
|
+
'image/tiff': 'tiff',
|
|
95
|
+
'text/html': 'html',
|
|
96
|
+
'text/plain': 'txt',
|
|
97
|
+
'text/markdown': 'md',
|
|
98
|
+
'text/javascript': 'js',
|
|
99
|
+
'audio/mpeg': 'mp3',
|
|
100
|
+
'audio/ogg': 'ogg',
|
|
101
|
+
'audio/mp4': 'm4a',
|
|
102
|
+
'video/mp4': 'mp4',
|
|
103
|
+
'video/quicktime': 'mov',
|
|
104
|
+
'video/ogg': 'ogv',
|
|
105
|
+
};
|
|
106
|
+
const out = { ...preferred };
|
|
107
|
+
for (const [ext, mime] of Object.entries(EXTENSION_TO_MIME)) {
|
|
108
|
+
if (!(mime in out))
|
|
109
|
+
out[mime] = ext;
|
|
110
|
+
}
|
|
111
|
+
// Non-canonical names some servers use for the same formats.
|
|
112
|
+
Object.assign(out, {
|
|
113
|
+
'audio/mp3': 'mp3',
|
|
114
|
+
'audio/x-wav': 'wav',
|
|
115
|
+
'audio/wave': 'wav',
|
|
116
|
+
'audio/vnd.wave': 'wav',
|
|
117
|
+
'audio/x-m4a': 'm4a',
|
|
118
|
+
'audio/x-flac': 'flac',
|
|
119
|
+
'application/x-zip-compressed': 'zip',
|
|
120
|
+
'image/vnd.microsoft.icon': 'ico',
|
|
121
|
+
});
|
|
122
|
+
return out;
|
|
123
|
+
})();
|
|
124
|
+
/**
|
|
125
|
+
* Content types that say nothing about the content. A Blob carrying one of these is treated as
|
|
126
|
+
* untyped.
|
|
127
|
+
*/
|
|
128
|
+
const GENERIC_MIME_TYPES = [
|
|
129
|
+
'',
|
|
130
|
+
'application/octet-stream',
|
|
131
|
+
'binary/octet-stream',
|
|
132
|
+
];
|
|
133
|
+
/** Lowercase `type/subtype` without parameters; `undefined` when empty or generic. */
|
|
134
|
+
const normalizeMimeType = (mimeType) => {
|
|
135
|
+
const t = (mimeType ?? '').split(';')[0].trim().toLowerCase();
|
|
136
|
+
if (!t || GENERIC_MIME_TYPES.includes(t) || !t.includes('/'))
|
|
137
|
+
return undefined;
|
|
138
|
+
return t;
|
|
139
|
+
};
|
|
140
|
+
/** MIME type for a path or file name by its extension, if it has a known one. */
|
|
141
|
+
const getMimeTypeFromPath = (filePathOrName) => {
|
|
142
|
+
const name = filePathOrName.split('/').pop() ?? '';
|
|
143
|
+
const dot = name.lastIndexOf('.');
|
|
144
|
+
if (dot <= 0 || dot === name.length - 1)
|
|
145
|
+
return undefined;
|
|
146
|
+
return EXTENSION_TO_MIME[name.slice(dot + 1).toLowerCase()];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* MIME type from the leading bytes, for formats with an unambiguous signature. Used when a local
|
|
150
|
+
* file has no (known) extension, e.g. a file seed named after its id.
|
|
151
|
+
*/
|
|
152
|
+
const sniffMimeType = (bytes) => {
|
|
153
|
+
const at = (offset, ...sig) => bytes.length >= offset + sig.length && sig.every((b, i) => bytes[offset + i] === b);
|
|
154
|
+
const ascii = (offset, s) => at(offset, ...Array.from(s).map((c) => c.charCodeAt(0)));
|
|
155
|
+
if (at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))
|
|
156
|
+
return 'image/png';
|
|
157
|
+
if (at(0, 0xff, 0xd8, 0xff))
|
|
158
|
+
return 'image/jpeg';
|
|
159
|
+
if (ascii(0, 'GIF87a') || ascii(0, 'GIF89a'))
|
|
160
|
+
return 'image/gif';
|
|
161
|
+
if (ascii(0, 'RIFF') && ascii(8, 'WEBP'))
|
|
162
|
+
return 'image/webp';
|
|
163
|
+
if (ascii(0, 'RIFF') && ascii(8, 'WAVE'))
|
|
164
|
+
return 'audio/wav';
|
|
165
|
+
if (ascii(0, 'RIFF') && ascii(8, 'AVI '))
|
|
166
|
+
return 'video/x-msvideo';
|
|
167
|
+
if (ascii(0, 'BM') && bytes.length > 14)
|
|
168
|
+
return 'image/bmp';
|
|
169
|
+
if (at(0, 0x49, 0x49, 0x2a, 0x00) || at(0, 0x4d, 0x4d, 0x00, 0x2a))
|
|
170
|
+
return 'image/tiff';
|
|
171
|
+
if (ascii(0, '%PDF-'))
|
|
172
|
+
return 'application/pdf';
|
|
173
|
+
if (ascii(0, 'OggS'))
|
|
174
|
+
return 'audio/ogg';
|
|
175
|
+
if (ascii(0, 'fLaC'))
|
|
176
|
+
return 'audio/flac';
|
|
177
|
+
if (ascii(0, 'ID3'))
|
|
178
|
+
return 'audio/mpeg';
|
|
179
|
+
if (at(0, 0x1a, 0x45, 0xdf, 0xa3))
|
|
180
|
+
return 'video/webm';
|
|
181
|
+
if (ascii(4, 'ftyp')) {
|
|
182
|
+
const brand = String.fromCharCode(...Array.from(bytes.slice(8, 12)));
|
|
183
|
+
if (brand === 'avif' || brand === 'avis')
|
|
184
|
+
return 'image/avif';
|
|
185
|
+
if (['heic', 'heix', 'heif', 'mif1', 'msf1'].includes(brand))
|
|
186
|
+
return 'image/heic';
|
|
187
|
+
if (brand === 'qt ')
|
|
188
|
+
return 'video/quicktime';
|
|
189
|
+
if (brand === 'M4A ')
|
|
190
|
+
return 'audio/mp4';
|
|
191
|
+
return 'video/mp4';
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Best MIME type for upload bytes: the source's own type (a Blob/File `type`) when it is specific,
|
|
197
|
+
* then the file name's extension, then the bytes' signature.
|
|
198
|
+
*/
|
|
199
|
+
const resolveUploadMimeType = (params) => normalizeMimeType(params.sourceType) ??
|
|
200
|
+
(params.fileName ? getMimeTypeFromPath(params.fileName) : undefined) ??
|
|
201
|
+
(params.bytes ? sniffMimeType(params.bytes) : undefined);
|
|
202
|
+
|
|
203
|
+
export { MIME_TO_EXTENSION as M, resolveUploadMimeType as r };
|
|
204
|
+
//# sourceMappingURL=mimeTypes-DHAHC4eZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mimeTypes-DHAHC4eZ.js","sources":["../../src/helpers/mimeTypes.ts"],"sourcesContent":["/**\n * File extension <-> MIME type, shared by the upload side (`getPublishUploads.ts`, which sets the\n * `Content-Type` tag) and the download worker (`browser/workers/filesDownload.ts`, which picks the\n * extension of a file saved under `files/`). The worker runs from a string and cannot import this\n * module, so {@link MIME_TO_EXTENSION} is injected into its source as JSON.\n */\n\n/**\n * Lowercase extension (no dot) to MIME type. Includes the odd extensions the SDK itself produces:\n * `saveImage` names a file `<id>.<subtype>` (e.g. `.svg+xml`, `.x-icon`), so subtypes appear here too.\n */\nexport const EXTENSION_TO_MIME: Readonly<Record<string, string>> = {\n // images\n png: 'image/png',\n apng: 'image/apng',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n jfif: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n avif: 'image/avif',\n heic: 'image/heic',\n heif: 'image/heif',\n svg: 'image/svg+xml',\n 'svg+xml': 'image/svg+xml',\n bmp: 'image/bmp',\n ico: 'image/x-icon',\n 'x-icon': 'image/x-icon',\n 'vnd.microsoft.icon': 'image/x-icon',\n tif: 'image/tiff',\n tiff: 'image/tiff',\n // text / documents\n html: 'text/html',\n htm: 'text/html',\n xhtml: 'application/xhtml+xml',\n json: 'application/json',\n txt: 'text/plain',\n plain: 'text/plain',\n md: 'text/markdown',\n markdown: 'text/markdown',\n csv: 'text/csv',\n tsv: 'text/tab-separated-values',\n xml: 'application/xml',\n css: 'text/css',\n js: 'text/javascript',\n mjs: 'text/javascript',\n pdf: 'application/pdf',\n rtf: 'application/rtf',\n epub: 'application/epub+zip',\n zip: 'application/zip',\n gz: 'application/gzip',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n odt: 'application/vnd.oasis.opendocument.text',\n // audio\n mp3: 'audio/mpeg',\n mpeg: 'audio/mpeg',\n wav: 'audio/wav',\n ogg: 'audio/ogg',\n oga: 'audio/ogg',\n opus: 'audio/opus',\n m4a: 'audio/mp4',\n aac: 'audio/aac',\n flac: 'audio/flac',\n weba: 'audio/webm',\n // video\n mp4: 'video/mp4',\n m4v: 'video/mp4',\n webm: 'video/webm',\n mov: 'video/quicktime',\n quicktime: 'video/quicktime',\n ogv: 'video/ogg',\n mkv: 'video/x-matroska',\n avi: 'video/x-msvideo',\n // fonts\n woff: 'font/woff',\n woff2: 'font/woff2',\n ttf: 'font/ttf',\n otf: 'font/otf',\n}\n\n/**\n * MIME type to the extension a downloaded file gets. One canonical extension per type (the\n * first one listed here wins over {@link EXTENSION_TO_MIME}'s aliases), plus a few common\n * non-canonical spellings a gateway may send.\n */\nexport const MIME_TO_EXTENSION: Readonly<Record<string, string>> = (() => {\n const preferred: Record<string, string> = {\n 'image/jpeg': 'jpg',\n 'image/svg+xml': 'svg',\n 'image/x-icon': 'ico',\n 'image/tiff': 'tiff',\n 'text/html': 'html',\n 'text/plain': 'txt',\n 'text/markdown': 'md',\n 'text/javascript': 'js',\n 'audio/mpeg': 'mp3',\n 'audio/ogg': 'ogg',\n 'audio/mp4': 'm4a',\n 'video/mp4': 'mp4',\n 'video/quicktime': 'mov',\n 'video/ogg': 'ogv',\n }\n const out: Record<string, string> = { ...preferred }\n for (const [ext, mime] of Object.entries(EXTENSION_TO_MIME)) {\n if (!(mime in out)) out[mime] = ext\n }\n // Non-canonical names some servers use for the same formats.\n Object.assign(out, {\n 'audio/mp3': 'mp3',\n 'audio/x-wav': 'wav',\n 'audio/wave': 'wav',\n 'audio/vnd.wave': 'wav',\n 'audio/x-m4a': 'm4a',\n 'audio/x-flac': 'flac',\n 'application/x-zip-compressed': 'zip',\n 'image/vnd.microsoft.icon': 'ico',\n })\n return out\n})()\n\n/**\n * Content types that say nothing about the content. A Blob carrying one of these is treated as\n * untyped.\n */\nexport const GENERIC_MIME_TYPES: readonly string[] = [\n '',\n 'application/octet-stream',\n 'binary/octet-stream',\n]\n\n/** Lowercase `type/subtype` without parameters; `undefined` when empty or generic. */\nexport const normalizeMimeType = (mimeType: string | null | undefined): string | undefined => {\n const t = (mimeType ?? '').split(';')[0]!.trim().toLowerCase()\n if (!t || GENERIC_MIME_TYPES.includes(t) || !t.includes('/')) return undefined\n return t\n}\n\n/** MIME type for a path or file name by its extension, if it has a known one. */\nexport const getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const name = filePathOrName.split('/').pop() ?? ''\n const dot = name.lastIndexOf('.')\n if (dot <= 0 || dot === name.length - 1) return undefined\n return EXTENSION_TO_MIME[name.slice(dot + 1).toLowerCase()]\n}\n\n/** Extension (no dot) for a MIME type, if it has a well-known one. */\nexport const getExtensionForMimeType = (mimeType: string | null | undefined): string | undefined => {\n const t = normalizeMimeType(mimeType)\n return t ? MIME_TO_EXTENSION[t] : undefined\n}\n\n/**\n * MIME type from the leading bytes, for formats with an unambiguous signature. Used when a local\n * file has no (known) extension, e.g. a file seed named after its id.\n */\nexport const sniffMimeType = (bytes: Uint8Array): string | undefined => {\n const at = (offset: number, ...sig: number[]) =>\n bytes.length >= offset + sig.length && sig.every((b, i) => bytes[offset + i] === b)\n const ascii = (offset: number, s: string) =>\n at(offset, ...Array.from(s).map((c) => c.charCodeAt(0)))\n\n if (at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a)) return 'image/png'\n if (at(0, 0xff, 0xd8, 0xff)) return 'image/jpeg'\n if (ascii(0, 'GIF87a') || ascii(0, 'GIF89a')) return 'image/gif'\n if (ascii(0, 'RIFF') && ascii(8, 'WEBP')) return 'image/webp'\n if (ascii(0, 'RIFF') && ascii(8, 'WAVE')) return 'audio/wav'\n if (ascii(0, 'RIFF') && ascii(8, 'AVI ')) return 'video/x-msvideo'\n if (ascii(0, 'BM') && bytes.length > 14) return 'image/bmp'\n if (at(0, 0x49, 0x49, 0x2a, 0x00) || at(0, 0x4d, 0x4d, 0x00, 0x2a)) return 'image/tiff'\n if (ascii(0, '%PDF-')) return 'application/pdf'\n if (ascii(0, 'OggS')) return 'audio/ogg'\n if (ascii(0, 'fLaC')) return 'audio/flac'\n if (ascii(0, 'ID3')) return 'audio/mpeg'\n if (at(0, 0x1a, 0x45, 0xdf, 0xa3)) return 'video/webm'\n if (ascii(4, 'ftyp')) {\n const brand = String.fromCharCode(...Array.from(bytes.slice(8, 12)))\n if (brand === 'avif' || brand === 'avis') return 'image/avif'\n if (['heic', 'heix', 'heif', 'mif1', 'msf1'].includes(brand)) return 'image/heic'\n if (brand === 'qt ') return 'video/quicktime'\n if (brand === 'M4A ') return 'audio/mp4'\n return 'video/mp4'\n }\n return undefined\n}\n\n/**\n * Best MIME type for upload bytes: the source's own type (a Blob/File `type`) when it is specific,\n * then the file name's extension, then the bytes' signature.\n */\nexport const resolveUploadMimeType = (params: {\n sourceType?: string | null\n fileName?: string | null\n bytes?: Uint8Array\n}): string | undefined =>\n normalizeMimeType(params.sourceType) ??\n (params.fileName ? getMimeTypeFromPath(params.fileName) : undefined) ??\n (params.bytes ? sniffMimeType(params.bytes) : undefined)\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;;;AAGG;AACI,MAAM,iBAAiB,GAAqC;;AAEjE,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,SAAS,EAAE,eAAe;AAC1B,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,cAAc;AACnB,IAAA,QAAQ,EAAE,cAAc;AACxB,IAAA,oBAAoB,EAAE,cAAc;AAC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AAED;;;AAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,MAIrC,KACC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC;AACpC,KAAC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;AACpE,KAAC,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;;"}
|
package/dist/node.js
CHANGED
|
@@ -1,46 +1,44 @@
|
|
|
1
1
|
import { enableMapSet } from 'immer';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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, m as eventEmitter } from './db-CQt-gcAl.js';
|
|
2
|
+
export { C as ConflictError, M as Model } from './index-8O3Uow-Y.js';
|
|
3
|
+
import { M as ModelPropertyDataTypes, P as Property, a2 as addModelsToDb, E as BaseDb } from './BasePathResolver-Cm4apKRb.js';
|
|
4
|
+
export { F as AmbiguousModelError, I as BasePathResolver, a3 as INIT_SCRIPT_SUCCESS_MESSAGE, a4 as SCHEMA_TS, h as appState, k as config, G as eventEmitter, a5 as getCorrectId, Q as isPublishedSeedRef, m as metadata, r as modelUids, s as models, O as normalizeRelationPropertyValue, N as resolveSeedIdsFromRefString, A as seeds, C as versions } from './BasePathResolver-Cm4apKRb.js';
|
|
6
5
|
import 'pluralize';
|
|
7
|
-
import { a as BaseDb } from './BasePathResolver-BdxCSIzn.js';
|
|
8
|
-
export { t as BasePathResolver, y as INIT_SCRIPT_SUCCESS_MESSAGE, S as SCHEMA_TS, b as appState, d as config, m as metadata, i as modelUids, j as models, r as seeds, v as versions } from './BasePathResolver-BdxCSIzn.js';
|
|
9
6
|
import 'drizzle-orm';
|
|
10
|
-
export { I as Item,
|
|
11
|
-
import { c as createPlatformServices } from './index.node-
|
|
12
|
-
export { D as Db, F as FileManager, P as PathResolver, r as resolveSdkDrizzleMigrationsDir } from './index.node-
|
|
13
|
-
export { g as getCorrectId, i as isPublishedSeedRef, n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString } from './tabEvents-BZJMY5uK.js';
|
|
7
|
+
export { I as Item, e as ItemProperty, f as ItemPropertySaveValidationError, O as OwnershipError, h as assertItemOwned, i as isItemOwned } from './Item-DBFchXpC.js';
|
|
8
|
+
import { c as createPlatformServices } from './index.node-CJhlcNHM.js';
|
|
9
|
+
export { D as Db, F as FileManager, P as PathResolver, r as resolveSdkDrizzleMigrationsDir } from './index.node-CJhlcNHM.js';
|
|
14
10
|
import yaml from 'js-yaml';
|
|
15
11
|
import fs__default, { readFileSync } from 'fs';
|
|
16
|
-
export { C as client,
|
|
12
|
+
export { C as client, g as getRefValueType, b as importJsonSchema, l as loadSchemaFromFile, r as readJsonImportFile, s as syncSchemaFromSource, t as transformImportToSchemaFile } from './ClientManager-i3nJASkg.js';
|
|
17
13
|
import { execSync } from 'child_process';
|
|
18
14
|
import path from 'path';
|
|
19
|
-
import { configurePlatform } from './configurePlatform-
|
|
15
|
+
import { configurePlatform } from './configurePlatform-D0lQGAMQ.js';
|
|
20
16
|
import 'xstate';
|
|
21
17
|
import 'debug';
|
|
22
18
|
import './model-DGMe-TTm.js';
|
|
23
19
|
import 'drizzle-orm/casing';
|
|
24
20
|
import '@sinclair/typebox';
|
|
25
|
-
import 'lodash-es';
|
|
26
|
-
import 'drizzle-orm/sqlite-core';
|
|
27
21
|
import '@seedprotocol/arweave';
|
|
28
|
-
import 'rxjs';
|
|
29
22
|
import '@seedprotocol/eas';
|
|
23
|
+
import 'drizzle-orm/sqlite-core';
|
|
24
|
+
import 'lodash-es';
|
|
25
|
+
import 'nanoid';
|
|
26
|
+
import 'nanoid-dictionary';
|
|
27
|
+
import '@seedprotocol/query';
|
|
28
|
+
import '@noble/hashes/sha256';
|
|
29
|
+
import '@noble/hashes/sha3';
|
|
30
|
+
import '@noble/hashes/utils';
|
|
31
|
+
import 'rxjs';
|
|
32
|
+
import './tabEvents-9s2WCYw-.js';
|
|
30
33
|
import 'fs/promises';
|
|
31
34
|
import 'url';
|
|
32
35
|
import 'node:url';
|
|
33
|
-
import './index-
|
|
36
|
+
import './index-AVFTVp1m.js';
|
|
34
37
|
import '@libsql/client';
|
|
35
38
|
import 'drizzle-orm/libsql';
|
|
36
39
|
import 'drizzle-orm/libsql/migrator';
|
|
37
40
|
import '@seedprotocol/arweave/node';
|
|
38
41
|
import '@seedprotocol/eas/node';
|
|
39
|
-
import 'nanoid';
|
|
40
|
-
import 'nanoid-dictionary';
|
|
41
|
-
import '@seedprotocol/query';
|
|
42
|
-
import '@noble/hashes/sha3';
|
|
43
|
-
import '@noble/hashes/utils';
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
44
|
* Parses markdown frontmatter from a file
|
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 // addModelsToDb reads property definitions from the model's snapshot context, not from `schema`;\n // without this it saves the model with no properties (and no Relation/List ref models).\n _getSnapshotContext: () => ({ properties: 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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K,CAAC,6CAA6C,CAAC;IAChE;AAEA,IAAA,MAAM,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;AACzC;AAEA;AACO,MAAM,WAAW,GAAG;;ACiB3B,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 // addModelsToDb reads property definitions from the model's snapshot context, not from `schema`;\n // without this it saves the model with no properties (and no Relation/List ref models).\n _getSnapshotContext: () => ({ properties: 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 { Model, Property } from '../Schema'\n\n// Core classes\nexport { Item } from '../Item/Item'\nexport { ItemProperty, ItemPropertySaveValidationError } from '../ItemProperty/ItemProperty'\nexport type { IItem, IItemProperty } from '../interfaces'\n\n// Errors\nexport { AmbiguousModelError } from '../Model/errors'\nexport { ConflictError, type ConflictResult } from '../Schema/errors'\nexport { OwnershipError, assertItemOwned, isItemOwned } from '../helpers/ownership'\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'\nexport type { MultiTabMode } from '../helpers/tabCoordinator'\nexport type { SyncFromEasOptions } from '../events/item/syncDbWithEas'\nexport type { HtmlEmbeddedDataUriPolicy } from '../helpers/property'\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,MAA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AsB,EAAE,CAAC;AAE3C,YAAY,EAAE;;"}
|
package/dist/platform.browser.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
export { c as createPlatformServices } from './index.browser-
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import 'drizzle-orm';
|
|
5
|
-
import '@seedprotocol/arweave';
|
|
6
|
-
import './tabEvents-BZJMY5uK.js';
|
|
1
|
+
export { c as createPlatformServices } from './index.browser-DBhxRoe8.js';
|
|
2
|
+
export { configurePlatform } from './configurePlatform-D0lQGAMQ.js';
|
|
3
|
+
import './BasePathResolver-Cm4apKRb.js';
|
|
7
4
|
import 'debug';
|
|
5
|
+
import '@seedprotocol/arweave';
|
|
8
6
|
import '@seedprotocol/eas';
|
|
9
7
|
import 'xstate';
|
|
10
8
|
import 'pluralize';
|
|
11
|
-
import '
|
|
9
|
+
import '@sinclair/typebox';
|
|
10
|
+
import 'drizzle-orm/sqlite-core';
|
|
11
|
+
import 'drizzle-orm';
|
|
12
12
|
import 'drizzle-orm/casing';
|
|
13
13
|
import 'lodash-es';
|
|
14
|
-
import '@sinclair/typebox';
|
|
15
14
|
import 'nanoid';
|
|
16
15
|
import 'nanoid-dictionary';
|
|
17
16
|
import '@seedprotocol/query';
|
|
18
|
-
import './errors-CrBxGWah.js';
|
|
19
|
-
import 'drizzle-orm/sqlite-proxy';
|
|
20
17
|
import '@noble/hashes/sha256';
|
|
18
|
+
import '@noble/hashes/sha3';
|
|
21
19
|
import '@noble/hashes/utils';
|
|
22
|
-
import './
|
|
20
|
+
import './tabEvents-9s2WCYw-.js';
|
|
21
|
+
import './mimeTypes-DHAHC4eZ.js';
|
|
22
|
+
import './errors-CrBxGWah.js';
|
|
23
|
+
import 'drizzle-orm/sqlite-proxy';
|
|
24
|
+
import './index-AVFTVp1m.js';
|
|
23
25
|
import 'sqlocal/drizzle';
|
|
24
26
|
import 'rxjs';
|
|
25
27
|
import 'graphql-request';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform.browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/platform.node.js
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
export { c as createPlatformServices } from './index.node-
|
|
1
|
+
export { c as createPlatformServices } from './index.node-CJhlcNHM.js';
|
|
2
2
|
import '@seedprotocol/arweave/node';
|
|
3
3
|
import '@seedprotocol/eas/node';
|
|
4
|
+
export { configurePlatform } from './configurePlatform-D0lQGAMQ.js';
|
|
4
5
|
import 'path';
|
|
5
6
|
import 'fs';
|
|
6
|
-
import './BasePathResolver-
|
|
7
|
+
import './BasePathResolver-Cm4apKRb.js';
|
|
8
|
+
import 'debug';
|
|
9
|
+
import '@seedprotocol/arweave';
|
|
10
|
+
import '@seedprotocol/eas';
|
|
11
|
+
import 'xstate';
|
|
12
|
+
import 'pluralize';
|
|
13
|
+
import '@sinclair/typebox';
|
|
7
14
|
import 'drizzle-orm/sqlite-core';
|
|
8
15
|
import 'drizzle-orm';
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
16
|
+
import 'drizzle-orm/casing';
|
|
17
|
+
import 'lodash-es';
|
|
18
|
+
import 'nanoid';
|
|
19
|
+
import 'nanoid-dictionary';
|
|
20
|
+
import '@seedprotocol/query';
|
|
21
|
+
import '@noble/hashes/sha256';
|
|
22
|
+
import '@noble/hashes/sha3';
|
|
23
|
+
import '@noble/hashes/utils';
|
|
11
24
|
import 'fs/promises';
|
|
12
25
|
import 'url';
|
|
13
26
|
import 'node:url';
|
|
14
|
-
import './index-
|
|
27
|
+
import './index-AVFTVp1m.js';
|
|
15
28
|
import '@libsql/client';
|
|
16
29
|
import 'drizzle-orm/libsql';
|
|
17
30
|
import 'drizzle-orm/libsql/migrator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.node.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform.node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import pluralize from 'pluralize';
|
|
2
|
-
import { r as resolveStorageNameToSchemaName } from './Item-
|
|
3
|
-
import {
|
|
2
|
+
import { r as resolveStorageNameToSchemaName } from './Item-DBFchXpC.js';
|
|
3
|
+
import { E as BaseDb, u as properties, s as models, g as normalizePropertyRecordSchema } from './BasePathResolver-Cm4apKRb.js';
|
|
4
|
+
export { M as ModelPropertyDataTypes, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, i as isDataType, n as normalizeDataType } from './BasePathResolver-Cm4apKRb.js';
|
|
4
5
|
import { and, eq } from 'drizzle-orm';
|
|
5
6
|
import { modelPropertiesToObject } from './model-DGMe-TTm.js';
|
|
6
|
-
import { l as normalizePropertyRecordSchema } from './db-CQt-gcAl.js';
|
|
7
|
-
export { B as Boolean, a as Date, F as File, H as Html, I as Image, J as Json, L as List, M as ModelPropertyDataTypes, N as Number, P as Property, b as PropertyConstructor, c as PropertyMetadataKey, R as Relation, T as THtmlEmbeddedDataUriPolicy, d as TProperty, e as TPropertyConstructor, f as TPropertyDataType, g as TPropertyDefs, h as TStorageType, j as Text, k as isDataType, n as normalizeDataType } from './db-CQt-gcAl.js';
|
|
8
7
|
import 'xstate';
|
|
9
8
|
import 'debug';
|
|
10
9
|
import 'rxjs';
|
|
11
10
|
import 'lodash-es';
|
|
12
11
|
import 'drizzle-orm/casing';
|
|
13
12
|
import '@seedprotocol/eas';
|
|
14
|
-
import './tabEvents-BZJMY5uK.js';
|
|
15
13
|
import '@seedprotocol/arweave';
|
|
14
|
+
import './tabEvents-9s2WCYw-.js';
|
|
15
|
+
import '@sinclair/typebox';
|
|
16
|
+
import 'drizzle-orm/sqlite-core';
|
|
16
17
|
import 'nanoid';
|
|
17
18
|
import 'nanoid-dictionary';
|
|
18
19
|
import '@seedprotocol/query';
|
|
19
|
-
import '
|
|
20
|
-
import '@
|
|
20
|
+
import '@noble/hashes/sha256';
|
|
21
|
+
import '@noble/hashes/sha3';
|
|
22
|
+
import '@noble/hashes/utils';
|
|
21
23
|
|
|
22
24
|
// Dynamic import to break circular dependency: Model -> ... -> helpers/property -> Model
|
|
23
25
|
// import { Model } from '@/Model/Model'
|
|
@@ -57,16 +59,16 @@ const getPropertySchema = async (modelName, propertyName,
|
|
|
57
59
|
/** Which model is meant when several schemas define one named modelName (Model.id and/or schema). */
|
|
58
60
|
scope = {}) => {
|
|
59
61
|
// Dynamic import to break circular dependency
|
|
60
|
-
const _mod_0 = await import('./index-
|
|
62
|
+
const _mod_0 = await import('./index-8O3Uow-Y.js');
|
|
61
63
|
const _ns_0 = _mod_0.f;
|
|
62
64
|
const modelMod = _ns_0;
|
|
63
65
|
const { Model } = modelMod;
|
|
64
|
-
const _mod_1 = await import('./Schema-
|
|
66
|
+
const _mod_1 = await import('./Schema-CpMNEnUO.js');
|
|
65
67
|
const _ns_1 = _mod_1.b;
|
|
66
68
|
const schemaMod = _ns_1;
|
|
67
69
|
const { Schema } = schemaMod;
|
|
68
|
-
const _mod_2 = await import('./
|
|
69
|
-
const _ns_2 = _mod_2.
|
|
70
|
+
const _mod_2 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
71
|
+
const _ns_2 = _mod_2.b1;
|
|
70
72
|
const { resolveModelRecord } = _ns_2;
|
|
71
73
|
const model = await Model.resolveAsync(modelName, scope);
|
|
72
74
|
if (!model) {
|
|
@@ -291,4 +293,4 @@ scope = {}) => {
|
|
|
291
293
|
};
|
|
292
294
|
|
|
293
295
|
export { getPropertySchema, normalizePropertyRecordSchema };
|
|
294
|
-
//# sourceMappingURL=property-
|
|
296
|
+
//# sourceMappingURL=property-DwPD283A.js.map
|