@seedprotocol/sdk 0.1.65 → 0.1.67
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/{index-D2LDMjA3.js → index-BJn9UAOX.js} +2 -2
- package/dist/index-BJn9UAOX.js.map +1 -0
- package/dist/{index-UWk43qGs.js → index-nGDuz8NN.js} +25 -19
- package/dist/index-nGDuz8NN.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-DA3JNobc.js → seed.schema.config-miFErQ6h.js} +2 -2
- package/dist/{seed.schema.config-DA3JNobc.js.map → seed.schema.config-miFErQ6h.js.map} +1 -1
- package/dist/src/allItems.ts +5 -0
- package/dist/src/arweave.ts +7 -0
- package/dist/src/saveImageSrc.ts +2 -2
- package/dist/src/write.ts +15 -51
- package/dist/types/src/browser/db/write.d.ts +0 -15
- package/dist/types/src/browser/db/write.d.ts.map +1 -1
- package/dist/types/src/browser/events/services/allItems.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/index.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/arweave.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-D2LDMjA3.js.map +0 -1
- package/dist/index-UWk43qGs.js.map +0 -1
- package/dist/src/save.ts +0 -183
- package/dist/src/saveListRelation.ts +0 -107
- package/dist/types/src/browser/db/save.d.ts +0 -5
- package/dist/types/src/browser/db/save.d.ts.map +0 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveListRelation.d.ts +0 -5
- package/dist/types/src/browser/property/actors/saveValueToDb/saveListRelation.d.ts.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { h as ImageSrc, I as Item, j as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, s as client, t as getCorrectId, r as getGlobalService, m as useCreateItem, o as useDeleteItem, p as useGlobalServiceStatus, k as useItem, l as useItemProperties, n as useItemProperty, u as useItems, q as useServices, w as withSeed } from './index-
|
|
1
|
+
export { h as ImageSrc, I as Item, j as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, s as client, t as getCorrectId, r as getGlobalService, m as useCreateItem, o as useDeleteItem, p as useGlobalServiceStatus, k as useItem, l as useItemProperties, n as useItemProperty, u as useItems, q as useServices, w as withSeed } from './index-nGDuz8NN.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import './constants-BLctWkrn.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as __decorate, a as __metadata } from './constants-BLctWkrn.js';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
|
-
import { T as Text, M as Model } from './index-
|
|
3
|
+
import { T as Text, M as Model } from './index-nGDuz8NN.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
@@ -74,4 +74,4 @@ const models = {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
export { models };
|
|
77
|
-
//# sourceMappingURL=seed.schema.config-
|
|
77
|
+
//# sourceMappingURL=seed.schema.config-miFErQ6h.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.schema.config-
|
|
1
|
+
{"version":3,"file":"seed.schema.config-miFErQ6h.js","sources":["../../src/shared/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/browser'\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/allItems.ts
CHANGED
|
@@ -18,6 +18,11 @@ export const saveServiceHandler = async (event: SaveServiceEvent) => {
|
|
|
18
18
|
|
|
19
19
|
const service = globalService.getSnapshot().context[nameOfService]
|
|
20
20
|
|
|
21
|
+
if (!service) {
|
|
22
|
+
console.log(`[saveServiceHandler] service not found: ${nameOfService}`)
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
await writeAppState(
|
|
22
27
|
`snapshot__${modelName}`,
|
|
23
28
|
JSON.stringify(service.getPersistedSnapshot()),
|
package/dist/src/arweave.ts
CHANGED
|
@@ -11,6 +11,13 @@ export const getArweave = (): Arweave | undefined => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (process.env.NODE_ENV === 'production') {
|
|
14
|
+
if (Object.keys(Arweave).includes('default')) {
|
|
15
|
+
return Arweave.default.init({
|
|
16
|
+
host: process.env.NEXT_PUBLIC_ARWEAVE_HOST,
|
|
17
|
+
protocol: 'https',
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
return Arweave.init({
|
|
15
22
|
host: process.env.NEXT_PUBLIC_ARWEAVE_HOST,
|
|
16
23
|
protocol: 'https',
|
package/dist/src/saveImageSrc.ts
CHANGED
|
@@ -166,7 +166,7 @@ export const saveImageSrc = fromCallback<
|
|
|
166
166
|
propertyValue: newImageSeedLocalId,
|
|
167
167
|
seedLocalId,
|
|
168
168
|
seedUid,
|
|
169
|
-
versionLocalId
|
|
169
|
+
versionLocalId,
|
|
170
170
|
versionUid,
|
|
171
171
|
modelName: itemModelName,
|
|
172
172
|
schemaUid,
|
|
@@ -184,7 +184,7 @@ export const saveImageSrc = fromCallback<
|
|
|
184
184
|
propertyName: propertyNameRaw,
|
|
185
185
|
newValue: newImageSeedLocalId,
|
|
186
186
|
seedLocalId,
|
|
187
|
-
versionLocalId
|
|
187
|
+
versionLocalId,
|
|
188
188
|
modelName: itemModelName,
|
|
189
189
|
schemaUid,
|
|
190
190
|
refSeedType: 'image',
|
package/dist/src/write.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sql } from 'drizzle-orm'
|
|
2
1
|
import { generateId } from '@/shared/helpers'
|
|
3
2
|
import { ModelValues } from '@/types'
|
|
4
3
|
import { escapeSqliteString } from '@/shared/helpers/db'
|
|
@@ -7,10 +6,11 @@ import { getVersionData } from '@/browser/db/read/getVersionData'
|
|
|
7
6
|
import debug from 'debug'
|
|
8
7
|
import { eventEmitter } from '@/eventBus'
|
|
9
8
|
import { getAppDb, runQueryForStatement } from '@/browser/db/sqlWasmClient'
|
|
10
|
-
import { appState, MetadataType, seeds } from '@/shared/seedSchema'
|
|
9
|
+
import { appState, metadata, MetadataType, seeds } from '@/shared/seedSchema'
|
|
11
10
|
import { createVersion } from '@/browser/db/write/createVersion'
|
|
12
11
|
import { createMetadata } from '@/browser/db/write/createMetadata'
|
|
13
12
|
import { getModel } from '@/browser/stores/modelClass'
|
|
13
|
+
import { and, eq, sql } from 'drizzle-orm'
|
|
14
14
|
|
|
15
15
|
const logger = debug('app:write')
|
|
16
16
|
|
|
@@ -53,53 +53,6 @@ type CreateMetadataForExistingRecord = (
|
|
|
53
53
|
props: CreateMetadataForExistingRecordProps,
|
|
54
54
|
) => Promise<void>
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Create a new metadata record from an existing record.
|
|
58
|
-
* @param existingRecord
|
|
59
|
-
* @param propertyName
|
|
60
|
-
* @param propertyValue
|
|
61
|
-
*/
|
|
62
|
-
export const createNewMetadataFromExistingRecord: CreateMetadataForExistingRecord =
|
|
63
|
-
async ({ existingRecord, propertyName, propertyValue }) => {
|
|
64
|
-
const appDb = getAppDb()
|
|
65
|
-
|
|
66
|
-
const newLocalId = generateId()
|
|
67
|
-
await appDb.run(
|
|
68
|
-
sql.raw(
|
|
69
|
-
`INSERT INTO metadata (local_id, seed_local_id, seed_uid, property_name, property_value, attestation_created_at,
|
|
70
|
-
schema_uid, model_type, version_local_id, version_uid, eas_data_type, ref_value_type,
|
|
71
|
-
ref_schema_uid, ref_seed_type, ref_resolved_value, ref_resolved_display_value,
|
|
72
|
-
attestation_raw)
|
|
73
|
-
VALUES ('${newLocalId}', '${existingRecord.seedLocalId}',
|
|
74
|
-
'${existingRecord.seedUid}' '${propertyName}', '${propertyValue}',
|
|
75
|
-
'${existingRecord.attestationCreatedAt}', '${existingRecord.schemaUid}',
|
|
76
|
-
'${existingRecord.modelType}',
|
|
77
|
-
'${existingRecord.versionLocalId}', '${existingRecord.versionUid}',
|
|
78
|
-
'${existingRecord.easDataType}', '${existingRecord.refValueType}',
|
|
79
|
-
'${existingRecord.refSchemaUid}', '${existingRecord.refSeedType}',
|
|
80
|
-
'${existingRecord.refResolvedValue}', '${existingRecord.refResolvedDisplayValue}',
|
|
81
|
-
'${existingRecord.attestationRaw}');
|
|
82
|
-
`,
|
|
83
|
-
),
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export const updateMetadataValue = async (
|
|
88
|
-
localId: string,
|
|
89
|
-
propertyValue: any,
|
|
90
|
-
) => {
|
|
91
|
-
const appDb = getAppDb()
|
|
92
|
-
|
|
93
|
-
await appDb.run(
|
|
94
|
-
sql.raw(
|
|
95
|
-
`UPDATE metadata
|
|
96
|
-
SET property_value = '${propertyValue}'
|
|
97
|
-
WHERE local_id = '${localId}';
|
|
98
|
-
`,
|
|
99
|
-
),
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
56
|
type CreateNewItemProps = Partial<ModelValues<any>> & {
|
|
104
57
|
modelName: string
|
|
105
58
|
}
|
|
@@ -121,8 +74,6 @@ export const createNewItem: CreateNewItem = async ({
|
|
|
121
74
|
throw new Error('A model name is required for createNewItem')
|
|
122
75
|
}
|
|
123
76
|
|
|
124
|
-
const appDb = getAppDb()
|
|
125
|
-
|
|
126
77
|
const seedType = modelName.toLowerCase()
|
|
127
78
|
|
|
128
79
|
const newSeedId = await createSeed({ type: seedType })
|
|
@@ -217,6 +168,19 @@ export const updateItemPropertyValue: UpdateItemPropertyValue = async ({
|
|
|
217
168
|
safeNewValue = escapeSqliteString(newValue)
|
|
218
169
|
}
|
|
219
170
|
|
|
171
|
+
const appDb = getAppDb()
|
|
172
|
+
|
|
173
|
+
const mostRecentRecordQuery = await appDb
|
|
174
|
+
.select()
|
|
175
|
+
.from(metadata)
|
|
176
|
+
.where(
|
|
177
|
+
and(
|
|
178
|
+
eq(metadata.propertyName, propertyName!),
|
|
179
|
+
eq(metadata.seedLocalId, seedLocalId!),
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
183
|
+
|
|
220
184
|
const mostRecentRecordStatement = `SELECT local_id,
|
|
221
185
|
uid,
|
|
222
186
|
property_name,
|
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import { ModelValues } from '@/types';
|
|
2
|
-
import { MetadataType } from '@/shared/seedSchema';
|
|
3
2
|
type CreateSeedProps = {
|
|
4
3
|
type: string;
|
|
5
4
|
seedUid?: string;
|
|
6
5
|
};
|
|
7
6
|
type CreateSeed = (props: CreateSeedProps) => Promise<string>;
|
|
8
7
|
export declare const createSeed: CreateSeed;
|
|
9
|
-
type CreateMetadataForExistingRecordProps = {
|
|
10
|
-
existingRecord: MetadataType;
|
|
11
|
-
propertyName: string;
|
|
12
|
-
propertyValue: any;
|
|
13
|
-
};
|
|
14
|
-
type CreateMetadataForExistingRecord = (props: CreateMetadataForExistingRecordProps) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new metadata record from an existing record.
|
|
17
|
-
* @param existingRecord
|
|
18
|
-
* @param propertyName
|
|
19
|
-
* @param propertyValue
|
|
20
|
-
*/
|
|
21
|
-
export declare const createNewMetadataFromExistingRecord: CreateMetadataForExistingRecord;
|
|
22
|
-
export declare const updateMetadataValue: (localId: string, propertyValue: any) => Promise<void>;
|
|
23
8
|
type CreateNewItemProps = Partial<ModelValues<any>> & {
|
|
24
9
|
modelName: string;
|
|
25
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../../src/browser/db/write.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../../src/browser/db/write.ts"],"names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rC,CAAA;AACD,eAAO,MAAM,aAAa,QAAe,MAAM,SAAS,MAAM,kBAe7D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allItems.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/events/services/allItems.ts"],"names":[],"mappings":"AAGA,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAiB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"allItems.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/events/services/allItems.ts"],"names":[],"mappings":"AAGA,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAiB,gBAAgB,kBAsB/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/property/actors/saveValueToDb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAEzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAEjC,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/property/actors/saveValueToDb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAEzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAEjC,eAAO,MAAM,YAAY,8HA4FvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arweave.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/schema/file/arweave.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,eAAO,MAAM,UAAU,QAAO,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"arweave.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/schema/file/arweave.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,eAAO,MAAM,UAAU,QAAO,OAAO,GAAG,SAyCvC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-D2LDMjA3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|