@seedprotocol/sdk 0.2.30 → 0.2.32
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/{ArweaveClient-C-HZgUWJ.js → ArweaveClient-BXD_aTsx.js} +2 -2
- package/dist/{ArweaveClient-rTTCUjiu.js.map → ArweaveClient-BXD_aTsx.js.map} +1 -1
- package/dist/{ArweaveClient-rTTCUjiu.js → ArweaveClient-CkcZD_QE.js} +2 -2
- package/dist/{ArweaveClient-C-HZgUWJ.js.map → ArweaveClient-CkcZD_QE.js.map} +1 -1
- package/dist/{Db-lX4nNJTb.js → Db-BKm58Z1E.js} +11 -9
- package/dist/{Db-lX4nNJTb.js.map → Db-BKm58Z1E.js.map} +1 -1
- package/dist/Db-xO-g5pKA.js +390 -0
- package/dist/Db-xO-g5pKA.js.map +1 -0
- package/dist/{EasClient-CKv5Eyao.js → EasClient-BNwSwDTO.js} +2 -2
- package/dist/{EasClient-nvmz2kCc.js.map → EasClient-BNwSwDTO.js.map} +1 -1
- package/dist/{EasClient-nvmz2kCc.js → EasClient-epqE9aWI.js} +2 -2
- package/dist/{EasClient-CKv5Eyao.js.map → EasClient-epqE9aWI.js.map} +1 -1
- package/dist/{FileManager-EGwM_VHY.js → FileManager-CXk83EW5.js} +4 -4
- package/dist/FileManager-CXk83EW5.js.map +1 -0
- package/dist/{FileManager-Bm_fGCH1.js → FileManager-DXi-X7r5.js} +2 -2
- package/dist/{FileManager-Bm_fGCH1.js.map → FileManager-DXi-X7r5.js.map} +1 -1
- package/dist/{Item-BRHX17yq.js → Item-DCdD-972.js} +5 -9
- package/dist/{Item-BRHX17yq.js.map → Item-DCdD-972.js.map} +1 -1
- package/dist/{ItemProperty-CZzIP1b8.js → ItemProperty-BlE3BrNc.js} +5 -9
- package/dist/{ItemProperty-CZzIP1b8.js.map → ItemProperty-BlE3BrNc.js.map} +1 -1
- package/dist/{QueryClient-CkqXe8Nk.js → QueryClient-Ckl99FYC.js} +2 -2
- package/dist/{QueryClient-CkqXe8Nk.js.map → QueryClient-Ckl99FYC.js.map} +1 -1
- package/dist/{QueryClient-pzZAYWa0.js → QueryClient-Do0C7Jnt.js} +2 -2
- package/dist/{QueryClient-pzZAYWa0.js.map → QueryClient-Do0C7Jnt.js.map} +1 -1
- package/dist/bin.js +6 -5
- package/dist/bin.js.map +1 -1
- package/dist/{constants-BjOTXEgm.js → constants-BakHTrB9.js} +2 -2
- package/dist/{constants-BjOTXEgm.js.map → constants-BakHTrB9.js.map} +1 -1
- package/dist/{index-BCmsQoYg.js → index-B2ovknu0.js} +112 -371
- package/dist/index-B2ovknu0.js.map +1 -0
- package/dist/{index-DzDVTUae.js → index-D3j5ZJGe.js} +5 -9
- package/dist/index-D3j5ZJGe.js.map +1 -0
- package/dist/main.js +6 -10
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-BswsDyRe.js → seed.schema.config-DQalKJ_d.js} +5 -9
- package/dist/seed.schema.config-DQalKJ_d.js.map +1 -0
- package/dist/src/BaseDb.ts +4 -0
- package/dist/src/BaseItem.ts +4 -0
- package/dist/src/Db.ts +5 -0
- package/dist/src/FileManager.ts +2 -2
- package/dist/src/IItem.ts +2 -1
- package/dist/src/SeedProtocolSdk.d.ts +0 -15
- package/dist/src/content-hash.ts +30 -0
- package/dist/src/create.ts +2 -2
- package/dist/src/createMetadata.ts +1 -1
- package/dist/src/download.ts +1 -1
- package/dist/src/getItem.ts +2 -3
- package/dist/src/getPublishPayload.ts +2 -8
- package/dist/src/hydrateFromDb.ts +2 -36
- package/dist/src/image-resize.ts +28 -0
- package/dist/src/migrate.ts +3 -241
- package/dist/src/preparePublishRequestData.ts +2 -2
- package/dist/src/propertyMachine.ts +1 -1
- package/dist/src/requestAll.ts +3 -3
- package/dist/src/saveImageSrc.ts +4 -0
- package/dist/src/saveItemStorage.ts +1 -1
- package/dist/src/upload.ts +2 -2
- package/dist/src/waitForDb.ts +18 -17
- package/dist/types/src/Item/BaseItem.d.ts +11 -1
- package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/service/actors/saveValueToDb/saveImageSrc.d.ts.map +1 -1
- package/dist/types/src/browser/db/Db.d.ts +2 -0
- package/dist/types/src/browser/db/Db.d.ts.map +1 -1
- package/dist/types/src/browser/index.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts +3 -2
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/workers/content-hash.d.ts +2 -0
- package/dist/types/src/browser/workers/content-hash.d.ts.map +1 -0
- package/dist/types/src/browser/workers/image-resize.d.ts +2 -0
- package/dist/types/src/browser/workers/image-resize.d.ts.map +1 -0
- package/dist/types/src/db/Db/BaseDb.d.ts +1 -0
- package/dist/types/src/db/Db/BaseDb.d.ts.map +1 -1
- package/dist/types/src/db/read/getItem.d.ts.map +1 -1
- package/dist/types/src/db/read/getPublishPayload.d.ts +2 -2
- package/dist/types/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/helpers/ArweaveClient/queries.d.ts.map +1 -0
- package/dist/types/src/helpers/index.d.ts +1 -3
- package/dist/types/src/helpers/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItem.d.ts +1 -0
- package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/types/src/node/db/Db.d.ts +3 -0
- package/dist/types/src/node/db/Db.d.ts.map +1 -1
- package/dist/types/src/services/db/actors/migrate.d.ts +0 -1
- package/dist/types/src/services/db/actors/migrate.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -31
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/package.json +7 -14
- package/dist/Db-Bu5Y7_fn.js +0 -138
- package/dist/Db-Bu5Y7_fn.js.map +0 -1
- package/dist/FileManager-EGwM_VHY.js.map +0 -1
- package/dist/index-BCmsQoYg.js.map +0 -1
- package/dist/index-DzDVTUae.js.map +0 -1
- package/dist/seed.schema.config-BswsDyRe.js.map +0 -1
- package/dist/src/logger.ts +0 -33
- package/dist/types/src/browser/arweave/queries.d.ts.map +0 -1
- package/dist/types/src/helpers/logger.d.ts +0 -7
- package/dist/types/src/helpers/logger.d.ts.map +0 -1
- /package/dist/types/src/{browser/arweave → helpers/ArweaveClient}/queries.d.ts +0 -0
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
export { I as Item } from './index-
|
|
1
|
+
export { I as Item } from './index-B2ovknu0.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import 'tslib';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
|
+
import 'eventemitter3';
|
|
6
7
|
import 'drizzle-orm';
|
|
7
8
|
import 'react';
|
|
8
|
-
import 'dayjs';
|
|
9
9
|
import 'nanoid';
|
|
10
10
|
import 'nanoid-dictionary';
|
|
11
11
|
import '@zenfs/core';
|
|
12
12
|
import 'debug';
|
|
13
13
|
import 'drizzle-orm/sqlite-core';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-BakHTrB9.js';
|
|
15
15
|
import '@ethereum-attestation-service/eas-sdk';
|
|
16
16
|
import 'xstate';
|
|
17
17
|
import 'pluralize';
|
|
18
|
-
import 'eventemitter3';
|
|
19
18
|
import 'lodash-es';
|
|
20
19
|
import '@statelyai/inspect';
|
|
21
|
-
import 'drizzle-orm/sqlite-proxy';
|
|
22
|
-
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
23
|
-
import 'drizzle-orm/migrator';
|
|
24
20
|
import 'node:fs';
|
|
25
21
|
import '@zenfs/dom';
|
|
26
22
|
import 'path';
|
|
27
23
|
import 'arweave';
|
|
24
|
+
import 'rxjs';
|
|
28
25
|
import 'use-immer';
|
|
29
26
|
import '@xstate/react';
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=index-DzDVTUae.js.map
|
|
27
|
+
//# sourceMappingURL=index-D3j5ZJGe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D3j5ZJGe.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import 'immer';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
export { D as Db,
|
|
3
|
+
export { D as Db, c as ImageSrc, d as Item, e as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, r as eventEmitter, p as getCorrectId, q as getGlobalService, h as useCreateItem, j as useDeleteItem, k as useGlobalServiceStatus, f as useItem, g as useItemProperties, i as useItemProperty, u as useItems, m as usePersistedSnapshots, l as usePublishItem, o as useService, n as useServices, s as withSeed } from './index-B2ovknu0.js';
|
|
4
|
+
export { B as BaseArweaveClient, a as BaseEasClient, c as BaseFileManager, b as BaseQueryClient } from './constants-BakHTrB9.js';
|
|
4
5
|
import 'tslib';
|
|
5
|
-
import 'drizzle-orm';
|
|
6
|
-
export { B as BaseArweaveClient, a as BaseEasClient, c as BaseFileManager, b as BaseQueryClient } from './constants-BjOTXEgm.js';
|
|
7
6
|
import '@sinclair/typebox';
|
|
7
|
+
import 'eventemitter3';
|
|
8
|
+
import 'drizzle-orm';
|
|
8
9
|
import 'react';
|
|
9
|
-
import 'dayjs';
|
|
10
10
|
import 'nanoid';
|
|
11
11
|
import 'nanoid-dictionary';
|
|
12
12
|
import '@zenfs/core';
|
|
@@ -14,18 +14,14 @@ import 'debug';
|
|
|
14
14
|
import 'drizzle-orm/sqlite-core';
|
|
15
15
|
import 'xstate';
|
|
16
16
|
import 'pluralize';
|
|
17
|
-
import 'eventemitter3';
|
|
18
17
|
import 'lodash-es';
|
|
19
18
|
import '@statelyai/inspect';
|
|
20
|
-
import 'drizzle-orm/sqlite-proxy';
|
|
21
|
-
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
22
|
-
import 'drizzle-orm/migrator';
|
|
23
19
|
import 'node:fs';
|
|
24
20
|
import '@zenfs/dom';
|
|
25
21
|
import 'path';
|
|
26
22
|
import 'arweave';
|
|
27
|
-
import 'use-immer';
|
|
28
|
-
import '@xstate/react';
|
|
29
23
|
import 'rxjs';
|
|
30
24
|
import '@ethereum-attestation-service/eas-sdk';
|
|
25
|
+
import 'use-immer';
|
|
26
|
+
import '@xstate/react';
|
|
31
27
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
import { T as Text, M as Model } from './index-
|
|
3
|
+
import { T as Text, M as Model } from './index-B2ovknu0.js';
|
|
4
4
|
import 'immer';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
|
+
import 'eventemitter3';
|
|
6
7
|
import 'drizzle-orm';
|
|
7
8
|
import 'react';
|
|
8
|
-
import 'dayjs';
|
|
9
9
|
import 'nanoid';
|
|
10
10
|
import 'nanoid-dictionary';
|
|
11
11
|
import '@zenfs/core';
|
|
12
12
|
import 'debug';
|
|
13
13
|
import 'drizzle-orm/sqlite-core';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-BakHTrB9.js';
|
|
15
15
|
import '@ethereum-attestation-service/eas-sdk';
|
|
16
16
|
import 'xstate';
|
|
17
17
|
import 'pluralize';
|
|
18
|
-
import 'eventemitter3';
|
|
19
18
|
import 'lodash-es';
|
|
20
19
|
import '@statelyai/inspect';
|
|
21
|
-
import 'drizzle-orm/sqlite-proxy';
|
|
22
|
-
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
23
|
-
import 'drizzle-orm/migrator';
|
|
24
20
|
import 'node:fs';
|
|
25
21
|
import '@zenfs/dom';
|
|
26
22
|
import 'path';
|
|
27
23
|
import 'arweave';
|
|
24
|
+
import 'rxjs';
|
|
28
25
|
import 'use-immer';
|
|
29
26
|
import '@xstate/react';
|
|
30
|
-
import 'rxjs';
|
|
31
27
|
|
|
32
28
|
let Seed = class Seed {
|
|
33
29
|
};
|
|
@@ -75,4 +71,4 @@ const models = {
|
|
|
75
71
|
};
|
|
76
72
|
|
|
77
73
|
export { models };
|
|
78
|
-
//# sourceMappingURL=seed.schema.config-
|
|
74
|
+
//# sourceMappingURL=seed.schema.config-DQalKJ_d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.schema.config-DQalKJ_d.js","sources":["../../src/db/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/schema'\n\n@Model\nclass Seed {\n @Text() uid!: string\n @Text() type!: string\n}\n\n@Model\nclass Version {\n @Text() seedUid!: string\n @Text() note!: string\n}\n\n@Model\nclass Metadata {\n @Text() key!: string\n @Text() value!: string\n}\n\nexport const models = {\n Seed,\n Version,\n Metadata,\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,IAAI,GAAV,MAAM,IAAI,CAAA;CAGT;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,IAAI,GAAA,UAAA,CAAA;IADT;AACK,CAAA,EAAA,IAAI,CAGT;AAGD,IAAM,OAAO,GAAb,MAAM,OAAO,CAAA;CAGZ;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAiB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,OAAO,GAAA,UAAA,CAAA;IADZ;AACK,CAAA,EAAA,OAAO,CAGZ;AAGD,IAAM,QAAQ,GAAd,MAAM,QAAQ,CAAA;CAGb;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}
|
package/dist/src/BaseDb.ts
CHANGED
|
@@ -28,4 +28,8 @@ export abstract class BaseDb implements IDb {
|
|
|
28
28
|
return this.PlatformClass.connectToDb(pathToDir, dbName)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
static async migrate(pathToDbDir: string, dbName: string): Promise<void> {
|
|
32
|
+
return this.PlatformClass.migrate(pathToDbDir, dbName)
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
}
|
package/dist/src/BaseItem.ts
CHANGED
|
@@ -388,6 +388,10 @@ export abstract class BaseItem<T extends ModelValues<ModelSchema>> implements II
|
|
|
388
388
|
return this._propertiesSubject.value
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
get attestationCreatedAt(): number {
|
|
392
|
+
return this.serviceContext.attestationCreatedAt as number
|
|
393
|
+
}
|
|
394
|
+
|
|
391
395
|
unload(): void {
|
|
392
396
|
this._subscription?.unsubscribe()
|
|
393
397
|
this._service.stop()
|
package/dist/src/Db.ts
CHANGED
|
@@ -66,6 +66,11 @@ class Db extends BaseDb implements IDb {
|
|
|
66
66
|
id: drizzle(nodeDbConfig).$client.name
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
static async migrate(pathToDbDir: string, dbName: string) {
|
|
71
|
+
const nodeDbConfig = getConfig(pathToDbDir)
|
|
72
|
+
return drizzle(nodeDbConfig)
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
BaseDb.setPlatformClass(Db)
|
package/dist/src/FileManager.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as fsAsync from 'fs/promises';
|
|
2
2
|
import { BaseFileManager } from '@/helpers/FileManager/BaseFileManager';
|
|
3
3
|
|
|
4
4
|
class FileManager extends BaseFileManager {
|
|
5
5
|
static async readFileAsBuffer(filePath: string): Promise<Buffer> {
|
|
6
|
-
return await
|
|
6
|
+
return await fsAsync.readFile(filePath);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
}
|
package/dist/src/IItem.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActorRefFrom, Subscription } from 'xstate'
|
|
2
|
-
import { ModelSchema, ModelValues,
|
|
2
|
+
import { ModelSchema, ModelValues, PropertyData } from '@/types'
|
|
3
3
|
import { VersionsType } from '@/seedSchema/VersionSchema'
|
|
4
4
|
import { IItemProperty } from './IItemProperty'
|
|
5
5
|
|
|
@@ -19,4 +19,5 @@ export interface IItem<T extends ModelValues<ModelSchema>> {
|
|
|
19
19
|
readonly latestVersionUid: VersionsType
|
|
20
20
|
readonly modelName: string
|
|
21
21
|
readonly properties: Record<string, IItemProperty<any>>
|
|
22
|
+
readonly attestationCreatedAt: number
|
|
22
23
|
}
|
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
export interface SeedProtocolSdk {
|
|
2
|
-
// Exported classes
|
|
3
|
-
Item: typeof import('@/browser/Item/Item').Item;
|
|
4
|
-
ItemProperty: typeof import('@/browser/property/ItemProperty').ItemProperty;
|
|
5
2
|
|
|
6
|
-
// Exported hooks
|
|
7
|
-
useItems: typeof import('@/browser').useItems;
|
|
8
|
-
useItem: typeof import('@/browser').useItem;
|
|
9
|
-
useItemProperties: typeof import('@/browser').useItemProperties;
|
|
10
|
-
useCreateItem: typeof import('@/browser').useCreateItem;
|
|
11
|
-
useItemProperty: typeof import('@/browser').useItemProperty;
|
|
12
|
-
useDeleteItem: typeof import('@/browser').useDeleteItem;
|
|
13
|
-
useGlobalServiceStatus: typeof import('@/browser').useGlobalServiceStatus;
|
|
14
|
-
useServices: typeof import('@/browser').useServices;
|
|
15
|
-
|
|
16
|
-
// Exported functions
|
|
17
|
-
getGlobalService: typeof import('@/browser').getGlobalService;
|
|
18
3
|
getCorrectId: typeof import('@/helpers').getCorrectId;
|
|
19
4
|
|
|
20
5
|
// Exported constants
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const hashLargeString = async ( input: string, ): Promise<string> => {
|
|
2
|
+
// Convert the string to an ArrayBuffer
|
|
3
|
+
const encoder = new TextEncoder()
|
|
4
|
+
const data = encoder.encode(input,)
|
|
5
|
+
|
|
6
|
+
// Hash the data with SHA-256
|
|
7
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data,)
|
|
8
|
+
|
|
9
|
+
// Convert the ArrayBuffer to a hex string
|
|
10
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer,),)
|
|
11
|
+
const hashHex = hashArray.map(( b, ) => b.toString(16,).padStart(2, '0',),).join('',)
|
|
12
|
+
|
|
13
|
+
return hashHex
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
onmessage = async (event,) => {
|
|
17
|
+
postMessage('Content hash worker received message',)
|
|
18
|
+
if (!event || !event.data || !event.data.trackingId || !event.data.base64) {
|
|
19
|
+
postMessage('No event data received',)
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
const { trackingId, base64, } = event.data
|
|
23
|
+
postMessage('Beginning content hash calculation',)
|
|
24
|
+
const contentHash = await hashLargeString(base64,)
|
|
25
|
+
postMessage('Content hash calculation complete',)
|
|
26
|
+
postMessage({
|
|
27
|
+
trackingId,
|
|
28
|
+
contentHash,
|
|
29
|
+
},)
|
|
30
|
+
}
|
package/dist/src/create.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Item } from '@/browser/Item'
|
|
2
1
|
import { eventEmitter } from '@/eventBus'
|
|
3
2
|
import { createItemCacheKey, getItemCache, updateItemCache } from './requestAll'
|
|
3
|
+
import { BaseItem } from '@/Item/BaseItem'
|
|
4
4
|
|
|
5
5
|
export const createItemRequestHandler = async (event) => {
|
|
6
6
|
const { ModelClass, itemData } = event
|
|
@@ -18,7 +18,7 @@ export const createItemRequestHandler = async (event) => {
|
|
|
18
18
|
return
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const newItem =
|
|
21
|
+
const newItem = await BaseItem.create({
|
|
22
22
|
modelName: ModelClass.originalConstructor.name,
|
|
23
23
|
...itemData,
|
|
24
24
|
})
|
|
@@ -25,7 +25,7 @@ export const createMetadata: CreateMetadata = async (
|
|
|
25
25
|
propertyRecordSchema.localStorageDir &&
|
|
26
26
|
propertyRecordSchema.storageType === 'ItemStorage'
|
|
27
27
|
) {
|
|
28
|
-
metadataValues.refResolvedValue = `${metadataValues.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
28
|
+
metadataValues.refResolvedValue = `${metadataValues.seedUid || metadataValues.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
29
29
|
metadataValues.refValueType = 'file'
|
|
30
30
|
}
|
|
31
31
|
|
package/dist/src/download.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { getGlobalService } from '@/services'
|
|
|
16
16
|
import { waitFor } from 'xstate'
|
|
17
17
|
import { getMetadata } from '@/db/read/getMetadata'
|
|
18
18
|
import { saveMetadata } from '@/db/write/saveMetadata'
|
|
19
|
-
import { GET_TRANSACTION_TAGS } from '@/
|
|
19
|
+
import { GET_TRANSACTION_TAGS } from '@/helpers/ArweaveClient/queries'
|
|
20
20
|
import { saveAppState } from '@/db/write/saveAppState'
|
|
21
21
|
import { BaseDb } from '@/db/Db/BaseDb'
|
|
22
22
|
import { BaseEasClient, BaseQueryClient, BaseArweaveClient } from '@/helpers'
|
package/dist/src/getItem.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Item } from '@/browser/Item'
|
|
2
1
|
import { getItemData } from './getItemData'
|
|
3
2
|
import { GetItem } from '@/types'
|
|
4
|
-
|
|
3
|
+
import { BaseItem } from '@/Item/BaseItem'
|
|
5
4
|
|
|
6
5
|
export const getItem: GetItem = async ({ modelName, seedLocalId, seedUid }) => {
|
|
7
6
|
const itemInitObj = await getItemData({
|
|
@@ -24,5 +23,5 @@ export const getItem: GetItem = async ({ modelName, seedLocalId, seedUid }) => {
|
|
|
24
23
|
return
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
return
|
|
26
|
+
return BaseItem.create(itemInitObj)
|
|
28
27
|
}
|
|
@@ -16,10 +16,10 @@ import pluralize from 'pluralize'
|
|
|
16
16
|
import { getSchemaUidForModel } from '@/db/read/getSchemaUidForModel'
|
|
17
17
|
import { getSchemaUidForSchemaDefinition } from '@/stores/eas'
|
|
18
18
|
import { getCorrectId } from '@/helpers'
|
|
19
|
-
import { Item } from '@/browser/Item/Item'
|
|
20
19
|
import { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'
|
|
21
20
|
import { IItemProperty } from '@/interfaces'
|
|
22
21
|
import { IItem } from '@/interfaces'
|
|
22
|
+
import { BaseItem } from '@/Item/BaseItem'
|
|
23
23
|
|
|
24
24
|
const getVersionUid = (item: IItem<any>) => {
|
|
25
25
|
let versionUid
|
|
@@ -272,15 +272,9 @@ type UploadedTransaction = {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
export const getPublishPayload = async (
|
|
275
|
-
item:
|
|
275
|
+
item: BaseItem<any>,
|
|
276
276
|
uploadedTransactions: UploadedTransaction[],
|
|
277
277
|
): Promise<MultiPublishPayload> => {
|
|
278
|
-
if (item.modelName === 'Post') {
|
|
279
|
-
item.authors = [
|
|
280
|
-
'Sr0bIx9Fwj',
|
|
281
|
-
'0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',
|
|
282
|
-
]
|
|
283
|
-
}
|
|
284
278
|
|
|
285
279
|
let multiPublishPayload: MultiPublishPayload = []
|
|
286
280
|
|
|
@@ -19,7 +19,6 @@ export const hydrateFromDb = fromCallback<
|
|
|
19
19
|
seedUid,
|
|
20
20
|
seedLocalId,
|
|
21
21
|
propertyName: propertyNameRaw,
|
|
22
|
-
propertyValue,
|
|
23
22
|
propertyRecordSchema,
|
|
24
23
|
modelName,
|
|
25
24
|
} = context
|
|
@@ -116,41 +115,6 @@ export const hydrateFromDb = fromCallback<
|
|
|
116
115
|
let propertyValueProcessed: string | string[] | undefined | null =
|
|
117
116
|
propertyValueFromDb
|
|
118
117
|
|
|
119
|
-
if (propertyName && !propertyNameFromDb) {
|
|
120
|
-
logger(
|
|
121
|
-
`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`,
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
propertyName &&
|
|
127
|
-
propertyNameFromDb &&
|
|
128
|
-
!propertyNameFromDb.includes(propertyName) &&
|
|
129
|
-
!propertyName.includes(propertyNameFromDb) &&
|
|
130
|
-
propertyNameFromDb !== propertyName
|
|
131
|
-
) {
|
|
132
|
-
logger(
|
|
133
|
-
`Property name from db ${propertyNameFromDb} does not match property name ${propertyName} for Property.${localId}`,
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (propertyValue && propertyValueFromDb !== propertyValue) {
|
|
138
|
-
logger(
|
|
139
|
-
`Property value from db ${propertyValueFromDb} does not match property value ${propertyValue} for Property.${localId}`,
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (seedLocalIdFromDb !== seedLocalId) {
|
|
144
|
-
logger(
|
|
145
|
-
`Seed local id from db ${seedLocalIdFromDb} does not match seed local id ${seedLocalId} for Property.${localId}`,
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (seedUidFromDb !== seedUid) {
|
|
150
|
-
logger(
|
|
151
|
-
`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`,
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
118
|
|
|
155
119
|
if (
|
|
156
120
|
propertyRecordSchema &&
|
|
@@ -194,6 +158,8 @@ export const hydrateFromDb = fromCallback<
|
|
|
194
158
|
propertyValueFromDb &&
|
|
195
159
|
propertyValueFromDb.length === 66
|
|
196
160
|
) {
|
|
161
|
+
// Here the storageTransactionId is stored on a different record and
|
|
162
|
+
// we want to add it as the refResolvedValue
|
|
197
163
|
const storageTransactionQuery = await appDb
|
|
198
164
|
.select({
|
|
199
165
|
propertyValue: metadata.propertyValue,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readAndCompressImage, } from "@misskey-dev/browser-image-resizer";
|
|
2
|
+
|
|
3
|
+
onmessage = async (e) => {
|
|
4
|
+
|
|
5
|
+
const { filePath, width, height } = e.data;
|
|
6
|
+
console.log('image-resize', filePath, width, height)
|
|
7
|
+
|
|
8
|
+
const root = await navigator.storage.getDirectory();
|
|
9
|
+
const fileHandle = await root.getFileHandle(filePath,);
|
|
10
|
+
|
|
11
|
+
const content = await fileHandle.getFile();
|
|
12
|
+
const resizedBlob = await readAndCompressImage(content, { maxWidth: 300 });
|
|
13
|
+
|
|
14
|
+
// Generate new file name with dimensions appended
|
|
15
|
+
const fileNameParts = filePath.split('.');
|
|
16
|
+
const extension = fileNameParts.pop();
|
|
17
|
+
const baseName = fileNameParts.join('.');
|
|
18
|
+
const newFileName = `${baseName}_${width}x${height}.${extension}`;
|
|
19
|
+
|
|
20
|
+
// Save resized image to OPFS with new name
|
|
21
|
+
const outputFileHandle = await root.getFileHandle(newFileName, { create: true });
|
|
22
|
+
const writable = await outputFileHandle.createWritable();
|
|
23
|
+
await writable.write(resizedBlob);
|
|
24
|
+
await writable.close();
|
|
25
|
+
|
|
26
|
+
self.postMessage(`Image resized and saved as ${newFileName}`);
|
|
27
|
+
|
|
28
|
+
}
|