@seedprotocol/sdk 0.3.0 → 0.3.1
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-CmJYeuq1.js → ArweaveClient-C0g0es2v.js} +2 -2
- package/dist/{ArweaveClient-EXXrXUzz.js.map → ArweaveClient-C0g0es2v.js.map} +1 -1
- package/dist/{ArweaveClient-EXXrXUzz.js → ArweaveClient-CzkBgiZY.js} +2 -2
- package/dist/{ArweaveClient-CmJYeuq1.js.map → ArweaveClient-CzkBgiZY.js.map} +1 -1
- package/dist/{Db-CESKJH-G.js → Db-C4oog-0n.js} +3 -3
- package/dist/{Db-CESKJH-G.js.map → Db-C4oog-0n.js.map} +1 -1
- package/dist/{Db-DiTPSbQ8.js → Db-VPouegkr.js} +3 -3
- package/dist/{Db-DiTPSbQ8.js.map → Db-VPouegkr.js.map} +1 -1
- package/dist/{EasClient-BesHK2bO.js → EasClient-B9a3NsTi.js} +2 -2
- package/dist/{EasClient-BesHK2bO.js.map → EasClient-B9a3NsTi.js.map} +1 -1
- package/dist/{EasClient-Cop6WtWl.js → EasClient-DQ93i2ci.js} +2 -2
- package/dist/{EasClient-Cop6WtWl.js.map → EasClient-DQ93i2ci.js.map} +1 -1
- package/dist/{FileManager-DTzkncLh.js → FileManager-_ErxVuwb.js} +8 -5
- package/dist/FileManager-_ErxVuwb.js.map +1 -0
- package/dist/{Item-B5Tz-Y7t.js → Item-D9HFPxsK.js} +3 -3
- package/dist/{Item-B5Tz-Y7t.js.map → Item-D9HFPxsK.js.map} +1 -1
- package/dist/{ItemProperty-DBV0Iib_.js → ItemProperty-BdtvKrEy.js} +3 -3
- package/dist/{ItemProperty-DBV0Iib_.js.map → ItemProperty-BdtvKrEy.js.map} +1 -1
- package/dist/{QueryClient-C7a0NHCt.js → QueryClient-Bmnv_moN.js} +2 -2
- package/dist/{QueryClient-C7a0NHCt.js.map → QueryClient-Bmnv_moN.js.map} +1 -1
- package/dist/{QueryClient-BnwbHtqe.js → QueryClient-hzOtFe99.js} +2 -2
- package/dist/{QueryClient-BnwbHtqe.js.map → QueryClient-hzOtFe99.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/bin.js.map +1 -1
- package/dist/{constants-CWg2B3Au.js → constants-Bhl5dZpN.js} +4 -1
- package/dist/constants-Bhl5dZpN.js.map +1 -0
- package/dist/{index-CQ9FS10O.js → index-BAtjd9W-.js} +3 -3
- package/dist/index-BAtjd9W-.js.map +1 -0
- package/dist/{index-BHGJ-Es9.js → index-BSR5hv7Q.js} +59 -27
- package/dist/index-BSR5hv7Q.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{seed.schema.config-DDzfQguf.js → seed.schema.config-BxJYabim.js} +3 -3
- package/dist/{seed.schema.config-DDzfQguf.js.map → seed.schema.config-BxJYabim.js.map} +1 -1
- package/dist/src/AppStateSchema.ts +10 -0
- package/dist/src/ArweaveClient.ts +13 -0
- package/dist/src/Attestation.ts +21 -0
- package/dist/src/BaseArweaveClient.ts +13 -0
- package/dist/src/BaseClientManager.ts +35 -0
- package/dist/src/BaseDb.ts +35 -0
- package/dist/src/BaseEasClient.ts +14 -0
- package/dist/src/BaseFileManager.ts +60 -0
- package/dist/src/BaseItem.ts +413 -0
- package/dist/src/BaseItemProperty.ts +416 -0
- package/dist/src/BaseQueryClient.ts +13 -0
- package/dist/src/ClientManager.ts +63 -0
- package/dist/src/ConfigSchema.ts +15 -0
- package/dist/src/Db.ts +82 -0
- package/dist/src/EasClient.ts +13 -0
- package/dist/src/FileDownloader.ts +63 -0
- package/dist/src/FileManager.ts +59 -0
- package/dist/src/IDb.ts +7 -0
- package/dist/src/IEasClient.ts +2 -0
- package/dist/src/IItem.ts +26 -0
- package/dist/src/IItemProperty.ts +28 -0
- package/dist/src/IQueryClient.ts +11 -0
- package/dist/src/ImageResizer.ts +81 -0
- package/dist/src/Item.ts +12 -0
- package/dist/src/ItemProperty.ts +9 -0
- package/dist/src/MetadataSchema.ts +28 -0
- package/dist/src/ModelSchema.ts +46 -0
- package/dist/src/ModelUidSchema.ts +16 -0
- package/dist/src/PropertyUidSchema.ts +16 -0
- package/dist/src/QueryClient.ts +26 -0
- package/dist/src/Schema.ts +17 -0
- package/dist/src/SeedProtocolSdk.d.ts +19 -0
- package/dist/src/SeedSchema.ts +29 -0
- package/dist/src/VersionSchema.ts +16 -0
- package/dist/src/actors.ts +295 -0
- package/dist/src/addModelsToDb.ts +152 -0
- package/dist/src/allItems.ts +31 -0
- package/dist/src/analyzeInput.ts +144 -0
- package/dist/src/browser.app.db.config.ts +27 -0
- package/dist/src/browser.ts +30 -0
- package/dist/src/checkStatus.ts +57 -0
- package/dist/src/clientManagerMachine.ts +59 -0
- package/dist/src/configureFs.ts +98 -0
- package/dist/src/connectToDb.ts +41 -0
- package/dist/src/connectionManager.ts +67 -0
- package/dist/src/constants.ts +125 -0
- package/dist/src/content-hash.ts +30 -0
- package/dist/src/create.ts +39 -0
- package/dist/src/createMetadata.ts +77 -0
- package/dist/src/createNewItem.ts +61 -0
- package/dist/src/createPublishAttempt.ts +16 -0
- package/dist/src/createSeed.ts +31 -0
- package/dist/src/createSeeds.ts +24 -0
- package/dist/src/createVersion.ts +33 -0
- package/dist/src/dbMachine.ts +182 -0
- package/dist/src/deleteItem.ts +19 -0
- package/dist/src/download.ts +208 -0
- package/dist/src/drizzle.ts +78 -0
- package/dist/src/eas.ts +40 -0
- package/dist/src/environment.ts +35 -0
- package/dist/src/eventBus.ts +5 -0
- package/dist/src/events.ts +14 -0
- package/dist/src/fetchDataFromEas.ts +94 -0
- package/dist/src/fetchDbData.ts +19 -0
- package/dist/src/fetchRelatedItems.ts +184 -0
- package/dist/src/fetchSeeds.ts +45 -0
- package/dist/src/fetchVersions.ts +49 -0
- package/dist/src/files.ts +81 -0
- package/dist/src/filesDownload.ts +326 -0
- package/dist/src/fragment-masking.ts +87 -0
- package/dist/src/getExistingItem.ts +60 -0
- package/dist/src/getItem.ts +32 -0
- package/dist/src/getItemData.ts +99 -0
- package/dist/src/getItemProperties.ts +56 -0
- package/dist/src/getItemProperty.ts +34 -0
- package/dist/src/getItems.ts +70 -0
- package/dist/src/getMetadata.ts +40 -0
- package/dist/src/getModelSchemas.ts +89 -0
- package/dist/src/getPropertyData.ts +50 -0
- package/dist/src/getPublishPayload.ts +355 -0
- package/dist/src/getPublishUploads.ts +207 -0
- package/dist/src/getRelationValueData.ts +27 -0
- package/dist/src/getSchemaForItemProperty.ts +68 -0
- package/dist/src/getSchemaForModel.ts +42 -0
- package/dist/src/getSchemaUidForModel.ts +32 -0
- package/dist/src/getSeedData.ts +34 -0
- package/dist/src/getSegmentedItemProperties.ts +65 -0
- package/dist/src/getStorageTransactionIdForSeedUid.ts +38 -0
- package/dist/src/getVersionData.ts +46 -0
- package/dist/src/getVersionsForVersionUids.ts +39 -0
- package/dist/src/globalMachine.ts +280 -0
- package/dist/src/gql.ts +118 -0
- package/dist/src/graphql.ts +3209 -0
- package/dist/src/helpers.ts +273 -0
- package/dist/src/hydrateExistingItem.ts +137 -0
- package/dist/src/hydrateFromDb.ts +270 -0
- package/dist/src/hydrateNewItem.ts +34 -0
- package/dist/src/imageResize.ts +507 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.ts +4 -0
- package/dist/src/initialize.ts +124 -0
- package/dist/src/internalMachine.ts +241 -0
- package/dist/src/itemMachineAll.ts +157 -0
- package/dist/src/itemMachineSingle.ts +158 -0
- package/dist/src/loadAppDb.ts +44 -0
- package/dist/src/machines.ts +66 -0
- package/dist/src/metadataLatest.ts +34 -0
- package/dist/src/migrate.ts +57 -0
- package/dist/src/model.ts +72 -0
- package/dist/src/modelClass.ts +19 -0
- package/dist/src/node.app.db.config.ts +41 -0
- package/dist/src/prepareDb.ts +29 -0
- package/dist/src/preparePublishRequestData.ts +81 -0
- package/dist/src/processItems.ts +74 -0
- package/dist/src/property.ts +156 -0
- package/dist/src/propertyMachine.ts +202 -0
- package/dist/src/publish.ts +28 -0
- package/dist/src/publishMachine.ts +77 -0
- package/dist/src/queries.ts +13 -0
- package/dist/src/recoverDeletedItem.ts +14 -0
- package/dist/src/reload.ts +33 -0
- package/dist/src/request.ts +45 -0
- package/dist/src/requestAll.ts +157 -0
- package/dist/src/resolveRelatedValue.ts +367 -0
- package/dist/src/resolveRemoteStorage.ts +88 -0
- package/dist/src/saveAppState.ts +50 -0
- package/dist/src/saveConfig.ts +106 -0
- package/dist/src/saveDataToDb.ts +145 -0
- package/dist/src/saveImageSrc.ts +242 -0
- package/dist/src/saveItemStorage.ts +156 -0
- package/dist/src/saveMetadata.ts +18 -0
- package/dist/src/savePublishService.ts +30 -0
- package/dist/src/saveRelation.ts +112 -0
- package/dist/src/seed.schema.config.ts +25 -0
- package/dist/src/seed.ts +10 -0
- package/dist/src/seedProtocol.ts +17 -0
- package/dist/src/services.ts +365 -0
- package/dist/src/setAddresses.ts +16 -0
- package/dist/src/sqlWasmClient.ts +88 -0
- package/dist/src/syncDbWithEas.ts +628 -0
- package/dist/src/trash.ts +29 -0
- package/dist/src/ts-to-proto.ts +101 -0
- package/dist/src/types.ts +12 -0
- package/dist/src/updateItemPropertyValue.ts +243 -0
- package/dist/src/updateMachineContext.ts +21 -0
- package/dist/src/updateMetadata.ts +59 -0
- package/dist/src/upload.ts +86 -0
- package/dist/src/validate.ts +45 -0
- package/dist/src/validateInput.ts +43 -0
- package/dist/src/validateItemData.ts +20 -0
- package/dist/src/versionData.ts +24 -0
- package/dist/src/waitForDb.ts +25 -0
- package/dist/src/waitForFiles.ts +41 -0
- package/dist/src/wasm.d.ts +8300 -0
- package/dist/types/scripts/bin.d.ts.map +1 -1
- package/dist/types/src/browser/helpers/FileManager.d.ts +2 -1
- package/dist/types/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts +1 -0
- package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/types/src/node/helpers/FileManager.d.ts +2 -1
- package/dist/types/src/node/helpers/FileManager.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/FileManager-DTzkncLh.js.map +0 -1
- package/dist/constants-CWg2B3Au.js.map +0 -1
- package/dist/index-BHGJ-Es9.js.map +0 -1
- package/dist/index-CQ9FS10O.js.map +0 -1
- package/dist/package.json +0 -189
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as fsAsync from 'fs/promises'
|
|
2
|
+
import { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'
|
|
3
|
+
|
|
4
|
+
class FileManager extends BaseFileManager {
|
|
5
|
+
|
|
6
|
+
static async getContentUrlFromPath( path: string ): Promise<string | undefined> {
|
|
7
|
+
return new Promise(( resolve, reject ) => {
|
|
8
|
+
reject(new Error('Not implemented'))
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static async initializeFileSystem(): Promise<void> {
|
|
13
|
+
return // No need to initialize file system in node
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static async downloadAllFiles(): Promise<void> {
|
|
17
|
+
return new Promise(( resolve, reject ) => {
|
|
18
|
+
reject(new Error('Not implemented'))
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static async resizeImage(): Promise<void> {
|
|
23
|
+
return new Promise(( resolve, reject ) => {
|
|
24
|
+
reject(new Error('Not implemented'))
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static async resizeAllImages(): Promise<void> {
|
|
29
|
+
return new Promise(( resolve, reject ) => {
|
|
30
|
+
reject(new Error('Not implemented'))
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async pathExists(filePath: string): Promise<boolean> {
|
|
35
|
+
return new Promise(( resolve, reject ) => {
|
|
36
|
+
reject(new Error('Not implemented'))
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static async createDirIfNotExists(filePath: string): Promise<void> {
|
|
41
|
+
return new Promise(( resolve, reject ) => {
|
|
42
|
+
reject(new Error('Not implemented'))
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static async readFileAsBuffer( filePath: string ): Promise<Buffer> {
|
|
47
|
+
return await fsAsync.readFile(filePath)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static async readFile(filePath: string): Promise<File> {
|
|
51
|
+
return new File([await fsAsync.readFile(filePath)], filePath)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
BaseFileManager.setPlatformClass(FileManager)
|
|
57
|
+
|
|
58
|
+
export { FileManager }
|
|
59
|
+
|
package/dist/src/IDb.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActorRefFrom, Subscription } from 'xstate'
|
|
2
|
+
import { ModelSchema, ModelValues, PropertyData } from '@/types'
|
|
3
|
+
import { VersionsType } from '@/seedSchema/VersionSchema'
|
|
4
|
+
import { IItemProperty } from './IItemProperty'
|
|
5
|
+
|
|
6
|
+
export interface IItem<T extends ModelValues<ModelSchema>> {
|
|
7
|
+
|
|
8
|
+
subscribe(callback: (itemProps: any) => void): Subscription
|
|
9
|
+
getService(): ActorRefFrom<any>
|
|
10
|
+
getEditedProperties(): Promise<PropertyData[]>
|
|
11
|
+
publish(): Promise<void>
|
|
12
|
+
getPublishUploads(): Promise<any>
|
|
13
|
+
getPublishPayload(uploadedTransactions: any[]): Promise<any>
|
|
14
|
+
unload(): void
|
|
15
|
+
|
|
16
|
+
readonly seedLocalId: string
|
|
17
|
+
readonly seedUid?: string
|
|
18
|
+
readonly schemaUid: string
|
|
19
|
+
readonly latestVersionUid: VersionsType
|
|
20
|
+
readonly latestVersionLocalId: string
|
|
21
|
+
readonly modelName: string
|
|
22
|
+
readonly properties: Record<string, IItemProperty<any>>
|
|
23
|
+
readonly attestationCreatedAt: number
|
|
24
|
+
readonly versionsCount: number
|
|
25
|
+
readonly lastVersionPublishedAt: number
|
|
26
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ActorRefFrom, Subscription } from 'xstate';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { Static } from '@sinclair/typebox';
|
|
4
|
+
import { TProperty } from '@/schema';
|
|
5
|
+
import { CreatePropertyInstanceProps } from '@/types';
|
|
6
|
+
|
|
7
|
+
export interface IItemProperty<PropertyType> {
|
|
8
|
+
|
|
9
|
+
readonly localId: string;
|
|
10
|
+
readonly uid: string;
|
|
11
|
+
readonly seedLocalId: string;
|
|
12
|
+
readonly seedUid: string;
|
|
13
|
+
readonly schemaUid: string;
|
|
14
|
+
readonly propertyName: string;
|
|
15
|
+
readonly modelName: string;
|
|
16
|
+
readonly propertyDef: Static<typeof TProperty> | undefined;
|
|
17
|
+
readonly localStoragePath: string | void;
|
|
18
|
+
readonly versionLocalId: string | undefined;
|
|
19
|
+
readonly status: any;
|
|
20
|
+
readonly alias: string | undefined;
|
|
21
|
+
value: any;
|
|
22
|
+
readonly published: boolean;
|
|
23
|
+
|
|
24
|
+
subscribe(callback: Partial<BehaviorSubject<any>>): Subscription;
|
|
25
|
+
save(): Promise<void>;
|
|
26
|
+
unload(): void;
|
|
27
|
+
getService(): ActorRefFrom<any>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
type FetchQueryOptions = {
|
|
3
|
+
queryKey: any
|
|
4
|
+
queryFn: () => Promise<any>
|
|
5
|
+
networkMode?: 'offlineFirst' | 'onlineOnly'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IQueryClient {
|
|
9
|
+
fetchQuery: (options: FetchQueryOptions) => Promise<any>
|
|
10
|
+
getQueryData: (queryKey: any) => any
|
|
11
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import fs from '@zenfs/core';
|
|
2
|
+
import imageResize from './imageResize'
|
|
3
|
+
import { FileManager } from '@/browser/helpers/FileManager';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class ImageResizer {
|
|
8
|
+
private cores: number
|
|
9
|
+
private workersArchive: Map<string, Worker> = new Map()
|
|
10
|
+
private workerBlobUrl: string
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
this.cores = Math.min(navigator.hardwareConcurrency || 4, 4);
|
|
14
|
+
|
|
15
|
+
this.workerBlobUrl = globalThis.URL.createObjectURL(
|
|
16
|
+
new Blob([imageResize], { type: 'application/javascript' })
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async resize({filePath, width, height}: ResizeImageParams) {
|
|
21
|
+
|
|
22
|
+
if (this.workersArchive.has(filePath)) {
|
|
23
|
+
const savedWorker = this.workersArchive.get(filePath)
|
|
24
|
+
savedWorker?.terminate()
|
|
25
|
+
console.log('[ImageResizer.resize] Terminated worker for filePath due to incoming request', filePath)
|
|
26
|
+
this.workersArchive.delete(filePath)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const worker = new Worker(this.workerBlobUrl);
|
|
30
|
+
|
|
31
|
+
this.workersArchive.set(filePath, worker)
|
|
32
|
+
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
worker.onmessage = (e) => {
|
|
35
|
+
console.log('[ImageResizer.resize] main thread onmessage', e.data);
|
|
36
|
+
if (e.data.done) {
|
|
37
|
+
const savedWorker = this.workersArchive.get(filePath)
|
|
38
|
+
savedWorker?.terminate()
|
|
39
|
+
console.log('[ImageResizer.resize] Terminated worker for filePath due to done', filePath)
|
|
40
|
+
this.workersArchive.delete(filePath)
|
|
41
|
+
resolve(e.data)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (e.data.error) {
|
|
45
|
+
reject(e.data.error)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
worker.postMessage({
|
|
50
|
+
filePath,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
});
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async resizeAll({width, height}: ResizeAllImagesParams) {
|
|
58
|
+
|
|
59
|
+
const imageDir = '/files/images'
|
|
60
|
+
let imageFilesStats = await fs.promises.readdir(imageDir, {
|
|
61
|
+
withFileTypes: true
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
imageFilesStats = imageFilesStats.filter(file => file.isFile())
|
|
65
|
+
|
|
66
|
+
const imageFiles = imageFilesStats.map(file => file.path)
|
|
67
|
+
|
|
68
|
+
const widthDir = `${imageDir}/${width}`
|
|
69
|
+
|
|
70
|
+
await FileManager.createDirIfNotExists(widthDir)
|
|
71
|
+
|
|
72
|
+
for (const imageFile of imageFiles) {
|
|
73
|
+
const resizedImageExists = await fs.promises.exists(`${widthDir}/${imageFile}`)
|
|
74
|
+
if (!resizedImageExists) {
|
|
75
|
+
await this.resize({filePath: `${imageDir}/${imageFile}`, width, height})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/src/Item.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IItem } from '@/interfaces';
|
|
2
|
+
import { BaseItem } from '@/Item/BaseItem';
|
|
3
|
+
import { ModelSchema, ModelValues, NewItemProps } from '@/types';
|
|
4
|
+
|
|
5
|
+
export class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {
|
|
6
|
+
constructor(initialValues: NewItemProps<T>) {
|
|
7
|
+
super(initialValues);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
BaseItem.setPlatformClass(Item)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IItemProperty } from '@/interfaces'
|
|
2
|
+
import { BaseItemProperty } from '@/ItemProperty/BaseItemProperty'
|
|
3
|
+
import { CreatePropertyInstanceProps, ModelSchema, ModelValues, } from '@/types'
|
|
4
|
+
|
|
5
|
+
export class ItemProperty<PropertyType> extends BaseItemProperty<PropertyType> implements IItemProperty<PropertyType> {
|
|
6
|
+
constructor(initialValues: Partial<CreatePropertyInstanceProps>) {
|
|
7
|
+
super(initialValues)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
export const metadata = sqliteTable('metadata', {
|
|
4
|
+
localId: text('local_id').unique(),
|
|
5
|
+
uid: text('uid'),
|
|
6
|
+
propertyName: text('property_name'),
|
|
7
|
+
propertyValue: text('property_value'),
|
|
8
|
+
schemaUid: text('schema_uid'),
|
|
9
|
+
modelType: text('model_type'),
|
|
10
|
+
seedLocalId: text('seed_local_id'),
|
|
11
|
+
seedUid: text('seed_uid'),
|
|
12
|
+
versionLocalId: text('version_local_id'),
|
|
13
|
+
versionUid: text('version_uid'),
|
|
14
|
+
easDataType: text('eas_data_type'),
|
|
15
|
+
refValueType: text('ref_value_type'),
|
|
16
|
+
refModelUid: text('ref_schema_uid'),
|
|
17
|
+
refSeedType: text('ref_seed_type'),
|
|
18
|
+
refResolvedValue: text('ref_resolved_value'),
|
|
19
|
+
refResolvedDisplayValue: text('ref_resolved_display_value'),
|
|
20
|
+
localStorageDir: text('local_storage_dir'),
|
|
21
|
+
attestationRaw: text('attestation_raw'),
|
|
22
|
+
attestationCreatedAt: int('attestation_created_at'),
|
|
23
|
+
contentHash: text('content_hash'),
|
|
24
|
+
createdAt: int('created_at'),
|
|
25
|
+
updatedAt: int('updated_at'),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export type MetadataType = metadata.$inferSelect
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { int, sqliteTable, text, unique } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { relations } from 'drizzle-orm'
|
|
3
|
+
|
|
4
|
+
export const models = sqliteTable('models', {
|
|
5
|
+
id: int('id').primaryKey({ autoIncrement: true }),
|
|
6
|
+
name: text('name').notNull(),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const modelsRelations = relations(models, ({ many }) => ({
|
|
10
|
+
properties: many(properties),
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
export type NewModelRecord = typeof models.$inferInsert
|
|
14
|
+
export type ModelRecordType = typeof models.$inferSelect
|
|
15
|
+
|
|
16
|
+
export const properties = sqliteTable(
|
|
17
|
+
'properties',
|
|
18
|
+
{
|
|
19
|
+
id: int('id').primaryKey({ autoIncrement: true }),
|
|
20
|
+
name: text('name').notNull(),
|
|
21
|
+
dataType: text('data_type').notNull(),
|
|
22
|
+
readEndpoint: text('read_endpoint'),
|
|
23
|
+
updateEndpoint: text('update_endpoint'),
|
|
24
|
+
modelId: int('model_id')
|
|
25
|
+
.notNull()
|
|
26
|
+
.references(() => models.id),
|
|
27
|
+
refModelId: int('ref_model_id').references(() => models.id),
|
|
28
|
+
refValueType: text('ref_value_type'),
|
|
29
|
+
},
|
|
30
|
+
(table) => {
|
|
31
|
+
return {
|
|
32
|
+
uniqueNameModelId: unique('unique_name_model_id').on(
|
|
33
|
+
table.name,
|
|
34
|
+
table.modelId,
|
|
35
|
+
),
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
export const propertiesRelations = relations(properties, ({ one }) => ({
|
|
41
|
+
model: one(models),
|
|
42
|
+
refModel: one(models),
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
export type NewPropertyRecord = typeof properties.$inferInsert
|
|
46
|
+
export type PropertyType = typeof properties.$inferSelect
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { relations } from 'drizzle-orm'
|
|
3
|
+
import { models } from './ModelSchema'
|
|
4
|
+
|
|
5
|
+
export const modelUids = sqliteTable('model_uids', {
|
|
6
|
+
id: int('id').primaryKey({ autoIncrement: true }),
|
|
7
|
+
uid: text('uid').notNull(),
|
|
8
|
+
modelId: int('model_id')
|
|
9
|
+
.notNull()
|
|
10
|
+
.unique()
|
|
11
|
+
.references(() => models.id),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const modelRelations = relations(modelUids, ({ many, one }) => ({
|
|
15
|
+
model: one(models),
|
|
16
|
+
}))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { relations } from 'drizzle-orm'
|
|
3
|
+
import { models, properties } from './ModelSchema'
|
|
4
|
+
|
|
5
|
+
export const propertyUids = sqliteTable('property_uids', {
|
|
6
|
+
id: int('id').primaryKey({ autoIncrement: true }),
|
|
7
|
+
uid: text('uid').notNull(),
|
|
8
|
+
propertyId: int('property_id')
|
|
9
|
+
.notNull()
|
|
10
|
+
.unique()
|
|
11
|
+
.references(() => models.id),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const propertyUidRelations = relations(propertyUids, ({ one }) => ({
|
|
15
|
+
property: one(properties),
|
|
16
|
+
}))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseQueryClient } from "@/helpers/QueryClient/BaseQueryClient"
|
|
2
|
+
import { IQueryClient } from '@/interfaces/IQueryClient'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class QueryClient extends BaseQueryClient {
|
|
7
|
+
static getQueryClient = (): IQueryClient=> {
|
|
8
|
+
return {
|
|
9
|
+
fetchQuery: async <T>({
|
|
10
|
+
queryKey,
|
|
11
|
+
queryFn,
|
|
12
|
+
}): Promise<T> => {
|
|
13
|
+
return await queryFn()
|
|
14
|
+
},
|
|
15
|
+
getQueryData: () => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
reject(new Error('Not implemented'))
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
BaseQueryClient.setPlatformClass(QueryClient)
|
|
25
|
+
|
|
26
|
+
export { QueryClient }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SeedProtocolSdk {
|
|
2
|
+
|
|
3
|
+
getCorrectId: typeof import('@/helpers').getCorrectId;
|
|
4
|
+
|
|
5
|
+
// Exported constants
|
|
6
|
+
eventEmitter: typeof import('@/eventBus').eventEmitter;
|
|
7
|
+
|
|
8
|
+
// Exported types
|
|
9
|
+
Model: typeof import('@/schema').Model;
|
|
10
|
+
Property: typeof import('@/schema').Property;
|
|
11
|
+
ImageSrc: typeof import('@/schema').ImageSrc;
|
|
12
|
+
List: typeof import('@/schema').List;
|
|
13
|
+
Text: typeof import('@/schema').Text;
|
|
14
|
+
Json: typeof import('@/schema').Json;
|
|
15
|
+
Relation: typeof import('@/schema').Relation;
|
|
16
|
+
|
|
17
|
+
// Node-specific exports
|
|
18
|
+
withSeed?: typeof import('@/node').withSeed;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
export const seeds = sqliteTable(
|
|
4
|
+
'seeds',
|
|
5
|
+
{
|
|
6
|
+
localId: text('local_id').unique(),
|
|
7
|
+
uid: text('uid'),
|
|
8
|
+
schemaUid: text('schema_uid'),
|
|
9
|
+
type: text('type'),
|
|
10
|
+
attestationRaw: text('attestation_raw'),
|
|
11
|
+
attestationCreatedAt: int('attestation_created_at'),
|
|
12
|
+
createdAt: int('created_at'),
|
|
13
|
+
updatedAt: int('updated_at'),
|
|
14
|
+
_markedForDeletion: int('_marked_for_deletion'),
|
|
15
|
+
},
|
|
16
|
+
// {
|
|
17
|
+
// triggers: [
|
|
18
|
+
// sql<string>`CREATE TRIGGER IF NOT EXISTS seeds_created_at_trigger
|
|
19
|
+
// BEFORE INSERT
|
|
20
|
+
// ON seeds
|
|
21
|
+
// FOR EACH ROW
|
|
22
|
+
// BEGIN
|
|
23
|
+
// SELECT strftime('%s', 'now') * 1000 INTO NEW.created_at;
|
|
24
|
+
// END;`,
|
|
25
|
+
// ],
|
|
26
|
+
// },
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export type SeedType = seeds.$inferSelect
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
export const versions = sqliteTable('versions', {
|
|
4
|
+
localId: text('local_id').unique(),
|
|
5
|
+
uid: text('uid'),
|
|
6
|
+
seedLocalId: text('seed_local_id'),
|
|
7
|
+
seedUid: text('seed_uid'),
|
|
8
|
+
seedType: text('seed_type'),
|
|
9
|
+
note: text('note'),
|
|
10
|
+
createdAt: int('created_at'),
|
|
11
|
+
updatedAt: int('updated_at'),
|
|
12
|
+
attestationCreatedAt: int('attestation_created_at'),
|
|
13
|
+
attestationRaw: text('attestation_raw'),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export type VersionsType = versions.$inferSelect
|