@seedprotocol/sdk 0.1.71 → 0.1.73
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/README.md +40 -19
- package/dist/bin.js +3 -1
- package/dist/bin.js.map +1 -1
- package/dist/{constants-BLctWkrn.js → constants-CtmwCBma.js} +23 -2
- package/dist/{constants-BLctWkrn.js.map → constants-CtmwCBma.js.map} +1 -1
- package/dist/{index-Cv-NmpW4.js → index-BmDmbqJM.js} +192 -55
- package/dist/index-BmDmbqJM.js.map +1 -0
- package/dist/{index-DXh19Ejc.js → index-Clo50o_L.js} +5 -3
- package/dist/index-Clo50o_L.js.map +1 -0
- package/dist/main.js +4 -2
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-Bp82HrfV.js → seed.schema.config-DfD4DkGq.js} +5 -3
- package/dist/seed.schema.config-DfD4DkGq.js.map +1 -0
- package/dist/src/ItemProperty.ts +4 -0
- package/dist/src/allItems.ts +3 -2
- package/dist/src/download.ts +2 -2
- package/dist/src/getPublishPayload.ts +111 -0
- package/dist/src/globalMachine.ts +46 -26
- package/dist/src/index.ts +19 -104
- package/dist/src/item.ts +5 -5
- package/dist/src/publish.ts +0 -3
- package/dist/src/saveAppState.ts +19 -0
- package/dist/src/savePublishService.ts +30 -0
- package/dist/src/seed.ts +31 -4
- package/dist/src/services.ts +13 -4
- package/dist/src/write.ts +1 -18
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts +15 -0
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -0
- package/dist/types/src/browser/db/write/saveAppState.d.ts +2 -0
- package/dist/types/src/browser/db/write/saveAppState.d.ts.map +1 -0
- package/dist/types/src/browser/db/write.d.ts +0 -1
- package/dist/types/src/browser/db/write.d.ts.map +1 -1
- package/dist/types/src/browser/events/item/index.d.ts.map +1 -1
- package/dist/types/src/browser/events/item/publish.d.ts +0 -1
- package/dist/types/src/browser/events/item/publish.d.ts.map +1 -1
- package/dist/types/src/browser/events/services/allItems.d.ts.map +1 -1
- package/dist/types/src/browser/item/Item.d.ts +1 -0
- package/dist/types/src/browser/item/Item.d.ts.map +1 -1
- package/dist/types/src/browser/item/queries.d.ts +3 -0
- package/dist/types/src/browser/item/queries.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts +1 -0
- package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/services.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/fetchAll/actors.d.ts.map +1 -1
- package/dist/types/src/browser/services/global/actors/savePublishService.d.ts +4 -0
- package/dist/types/src/browser/services/global/actors/savePublishService.d.ts.map +1 -0
- package/dist/types/src/browser/services/global/globalMachine.d.ts +20 -0
- package/dist/types/src/browser/services/global/globalMachine.d.ts.map +1 -1
- package/dist/types/src/shared/helpers/constants.d.ts +12 -0
- package/dist/types/src/shared/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/types/item.d.ts +2 -0
- package/dist/types/src/types/item.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-Cv-NmpW4.js.map +0 -1
- package/dist/index-DXh19Ejc.js.map +0 -1
- package/dist/seed.schema.config-Bp82HrfV.js.map +0 -1
- package/dist/src/seedData.ts +0 -0
- package/dist/types/src/browser/eas/actors.d.ts +0 -3
- package/dist/types/src/browser/eas/actors.d.ts.map +0 -1
- package/dist/types/src/browser/eas/helpers.d.ts +0 -5
- package/dist/types/src/browser/eas/helpers.d.ts.map +0 -1
- package/dist/types/src/browser/eas/index.d.ts +0 -113
- package/dist/types/src/browser/eas/index.d.ts.map +0 -1
- package/dist/types/src/browser/eas/seedData.d.ts +0 -1
- package/dist/types/src/browser/eas/seedData.d.ts.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './constants-
|
|
1
|
+
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-BmDmbqJM.js';
|
|
2
|
+
import './constants-CtmwCBma.js';
|
|
3
|
+
import '@ethereum-attestation-service/eas-sdk';
|
|
4
|
+
import 'thirdweb';
|
|
3
5
|
import 'path';
|
|
4
6
|
import 'reflect-metadata';
|
|
5
7
|
import '@sinclair/typebox';
|
|
@@ -27,4 +29,4 @@ import '@zenfs/dom';
|
|
|
27
29
|
import 'arweave';
|
|
28
30
|
import 'use-immer';
|
|
29
31
|
import '@xstate/react';
|
|
30
|
-
//# sourceMappingURL=index-
|
|
32
|
+
//# sourceMappingURL=index-Clo50o_L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Clo50o_L.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { j as ImageSrc, I as Item, k as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, v as getCorrectId, s as getGlobalService, n as useCreateItem, p as useDeleteItem, q as useGlobalServiceStatus, l as useItem, m as useItemProperties, o as useItemProperty, u as useItems, r as useServices, w as withSeed } from './index-BmDmbqJM.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
|
-
import './constants-
|
|
4
|
+
import './constants-CtmwCBma.js';
|
|
5
5
|
import 'xstate';
|
|
6
6
|
import 'arweave';
|
|
7
7
|
import 'drizzle-orm';
|
|
@@ -27,4 +27,6 @@ import 'drizzle-orm/sqlite-proxy';
|
|
|
27
27
|
import '@zenfs/dom';
|
|
28
28
|
import 'use-immer';
|
|
29
29
|
import '@xstate/react';
|
|
30
|
+
import 'thirdweb';
|
|
31
|
+
import '@ethereum-attestation-service/eas-sdk';
|
|
30
32
|
//# 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,12 +1,14 @@
|
|
|
1
|
-
import { _ as __decorate, a as __metadata } from './constants-
|
|
1
|
+
import { _ as __decorate, a as __metadata } from './constants-CtmwCBma.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-BmDmbqJM.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import 'arweave';
|
|
8
8
|
import '@zenfs/core';
|
|
9
9
|
import '@zenfs/dom';
|
|
10
|
+
import '@ethereum-attestation-service/eas-sdk';
|
|
11
|
+
import 'thirdweb';
|
|
10
12
|
import 'path';
|
|
11
13
|
import '@sinclair/typebox';
|
|
12
14
|
import 'dayjs';
|
|
@@ -74,4 +76,4 @@ const models = {
|
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
export { models };
|
|
77
|
-
//# sourceMappingURL=seed.schema.config-
|
|
79
|
+
//# sourceMappingURL=seed.schema.config-DfD4DkGq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.schema.config-DfD4DkGq.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/ItemProperty.ts
CHANGED
|
@@ -345,6 +345,10 @@ export class ItemProperty<PropertyType> {
|
|
|
345
345
|
return this._getSnapshot().context.seedUid
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
get schemaUid() {
|
|
349
|
+
return this._getSnapshot().context.schemaUid
|
|
350
|
+
}
|
|
351
|
+
|
|
348
352
|
get propertyName() {
|
|
349
353
|
if (this._alias) {
|
|
350
354
|
return this._alias
|
package/dist/src/allItems.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getGlobalService } from '@/browser/services/global'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { saveAppState } from '@/browser/db/write/saveAppState'
|
|
3
4
|
|
|
4
5
|
type SaveServiceEvent = {
|
|
5
6
|
modelName: string
|
|
@@ -23,7 +24,7 @@ export const saveServiceHandler = async (event: SaveServiceEvent) => {
|
|
|
23
24
|
return
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
await
|
|
27
|
+
await saveAppState(
|
|
27
28
|
`snapshot__${modelName}`,
|
|
28
29
|
JSON.stringify(service.getPersistedSnapshot()),
|
|
29
30
|
)
|
package/dist/src/download.ts
CHANGED
|
@@ -17,10 +17,10 @@ import debug from 'debug'
|
|
|
17
17
|
import { getAppDb, isAppDbReady } from '@/browser/db/sqlWasmClient'
|
|
18
18
|
import { getGlobalService } from '@/browser/services'
|
|
19
19
|
import { waitFor } from 'xstate'
|
|
20
|
-
import { writeAppState } from '@/browser/db/write'
|
|
21
20
|
import { getMetadata } from '@/browser/db/read/getMetadata'
|
|
22
21
|
import { saveMetadata } from '@/browser/db/write/saveMetadata'
|
|
23
22
|
import { GET_TRANSACTION_TAGS } from '@/browser/arweave/queries'
|
|
23
|
+
import { saveAppState } from '@/browser/db/write/saveAppState'
|
|
24
24
|
|
|
25
25
|
const logger = debug('app:files:download')
|
|
26
26
|
|
|
@@ -141,7 +141,7 @@ export const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
141
141
|
|
|
142
142
|
excludedTransactions.add(transactionId)
|
|
143
143
|
|
|
144
|
-
await
|
|
144
|
+
await saveAppState(
|
|
145
145
|
'excludedTransactions',
|
|
146
146
|
JSON.stringify(Array.from(excludedTransactions)),
|
|
147
147
|
)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { GET_SCHEMAS } from '@/browser'
|
|
2
|
+
import { getItem } from '@/browser/db/read/getItem'
|
|
3
|
+
import {
|
|
4
|
+
defaultAttestationData,
|
|
5
|
+
INTERNAL_DATA_TYPES,
|
|
6
|
+
VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,
|
|
7
|
+
} from '@/shared/helpers/constants'
|
|
8
|
+
import { ZERO_ADDRESS } from 'thirdweb'
|
|
9
|
+
import {
|
|
10
|
+
AttestationRequest,
|
|
11
|
+
SchemaEncoder,
|
|
12
|
+
} from '@ethereum-attestation-service/eas-sdk'
|
|
13
|
+
import { easClient, queryClient } from '@/browser/helpers'
|
|
14
|
+
|
|
15
|
+
type PublishPayload = {
|
|
16
|
+
localId: string
|
|
17
|
+
seedIsRevocable: boolean
|
|
18
|
+
seedSchemaUid: string
|
|
19
|
+
seedUid: string
|
|
20
|
+
versionSchemaUid: string
|
|
21
|
+
versionUid: string
|
|
22
|
+
listOfAttestations: AttestationRequest[]
|
|
23
|
+
propertiesToUpdate: any[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type MultiPublishPayload = PublishPayload[]
|
|
27
|
+
|
|
28
|
+
export const getPublishPayload = async (
|
|
29
|
+
seedLocalId: string,
|
|
30
|
+
): Promise<MultiPublishPayload> => {
|
|
31
|
+
const item = await getItem({ seedLocalId })
|
|
32
|
+
|
|
33
|
+
if (!item) {
|
|
34
|
+
throw new Error('Item not found')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const localId = item.seedLocalId
|
|
38
|
+
const seedIsRevocable = true
|
|
39
|
+
const seedSchemaUid = item.schemaUid
|
|
40
|
+
const seedUid = item.seedUid
|
|
41
|
+
const versionSchemaUid = VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA
|
|
42
|
+
const listOfAttestations = []
|
|
43
|
+
const propertiesToUpdate = []
|
|
44
|
+
|
|
45
|
+
for (const [propertyName, itemProperty] of Object.entries(item.properties)) {
|
|
46
|
+
if (!itemProperty.value) {
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const foundPropertySchema = await queryClient.fetchQuery({
|
|
51
|
+
queryKey: [`getPropertySchema${propertyName}`],
|
|
52
|
+
queryFn: async () =>
|
|
53
|
+
easClient.request(GET_SCHEMAS, {
|
|
54
|
+
where: {
|
|
55
|
+
id: {
|
|
56
|
+
equals: itemProperty.schemaUid,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
!foundPropertySchema ||
|
|
64
|
+
!foundPropertySchema.schemas ||
|
|
65
|
+
foundPropertySchema.schemas.length === 0
|
|
66
|
+
) {
|
|
67
|
+
console.error(`Property schema not found for ${propertyName}`)
|
|
68
|
+
continue
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!itemProperty.propertyDef) {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const easDataType =
|
|
76
|
+
INTERNAL_DATA_TYPES[itemProperty.propertyDef.dataType].eas
|
|
77
|
+
|
|
78
|
+
const data = [
|
|
79
|
+
{ name: propertyName, type: easDataType, value: itemProperty.value },
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
const easSchemaDefinition = foundPropertySchema.schemas[0].schema
|
|
83
|
+
|
|
84
|
+
const dataEncoder = new SchemaEncoder(easSchemaDefinition)
|
|
85
|
+
|
|
86
|
+
const encodedData = dataEncoder.encodeData(data)
|
|
87
|
+
|
|
88
|
+
listOfAttestations.push({
|
|
89
|
+
schema: itemProperty.schemaUid!,
|
|
90
|
+
data: [
|
|
91
|
+
{
|
|
92
|
+
...defaultAttestationData,
|
|
93
|
+
data: encodedData,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
localId,
|
|
102
|
+
seedIsRevocable,
|
|
103
|
+
seedSchemaUid,
|
|
104
|
+
seedUid: seedUid || ZERO_ADDRESS,
|
|
105
|
+
versionUid: item.latestVersionUid || ZERO_ADDRESS,
|
|
106
|
+
versionSchemaUid,
|
|
107
|
+
listOfAttestations,
|
|
108
|
+
propertiesToUpdate,
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
}
|
|
@@ -16,6 +16,7 @@ import { addModelsToDb } from '@/browser/services/global/actors/addModelsToDb'
|
|
|
16
16
|
import { internalMachine } from '@/browser/services/internal/internalMachine'
|
|
17
17
|
import { itemMachineAll } from '@/browser/item/all/itemMachineAll'
|
|
18
18
|
import { publishMachine } from '@/browser/services/publish/publishMachine'
|
|
19
|
+
import { savePublishService } from '@/browser/services/global/actors/savePublishService'
|
|
19
20
|
|
|
20
21
|
const {
|
|
21
22
|
UNINITIALIZED,
|
|
@@ -38,11 +39,17 @@ const globalMachine = setup({
|
|
|
38
39
|
initialize,
|
|
39
40
|
addModelsToDb,
|
|
40
41
|
getSchemaForModel,
|
|
42
|
+
savePublishService,
|
|
41
43
|
},
|
|
42
44
|
}).createMachine({
|
|
43
45
|
id: MachineIds.GLOBAL,
|
|
44
46
|
initial: UNINITIALIZED,
|
|
45
47
|
context: ({ input }) => input as GlobalMachineContext,
|
|
48
|
+
on: {
|
|
49
|
+
publishItemRequest: `.${PUBLISHING_ITEM}`,
|
|
50
|
+
savePublishService: `.savingPublishService`,
|
|
51
|
+
restorePublishService: `.${PUBLISHING_ITEM}`,
|
|
52
|
+
},
|
|
46
53
|
states: {
|
|
47
54
|
[UNINITIALIZED]: {
|
|
48
55
|
on: {
|
|
@@ -73,7 +80,7 @@ const globalMachine = setup({
|
|
|
73
80
|
displayText: 'Booting up',
|
|
74
81
|
percentComplete: 5,
|
|
75
82
|
},
|
|
76
|
-
tags: ['loading'],
|
|
83
|
+
tags: ['loading', 'startup'],
|
|
77
84
|
},
|
|
78
85
|
[INITIALIZING]: {
|
|
79
86
|
on: {
|
|
@@ -130,7 +137,7 @@ const globalMachine = setup({
|
|
|
130
137
|
displayText: 'Initializing Seed SDK',
|
|
131
138
|
percentComplete: 10,
|
|
132
139
|
},
|
|
133
|
-
tags: ['loading'],
|
|
140
|
+
tags: ['loading', 'startup'],
|
|
134
141
|
},
|
|
135
142
|
},
|
|
136
143
|
[ADDING_MODELS_TO_DB]: {
|
|
@@ -148,39 +155,52 @@ const globalMachine = setup({
|
|
|
148
155
|
meta: {
|
|
149
156
|
displayText: 'Adding models to database',
|
|
150
157
|
},
|
|
151
|
-
tags: ['loading'],
|
|
158
|
+
tags: ['loading', 'startup'],
|
|
152
159
|
},
|
|
153
160
|
},
|
|
154
161
|
[INITIALIZED]: {
|
|
155
|
-
type: 'parallel',
|
|
156
|
-
on: {
|
|
157
|
-
|
|
158
|
-
},
|
|
162
|
+
// type: 'parallel',
|
|
163
|
+
// on: {
|
|
164
|
+
// publishItemRequest: `.${PUBLISHING_ITEM}`,
|
|
165
|
+
// },
|
|
159
166
|
meta: {
|
|
160
167
|
displayText: 'Global service ready',
|
|
161
168
|
percentComplete: 40,
|
|
162
169
|
},
|
|
163
|
-
tags: ['loading'],
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
tags: ['loading', 'startup'],
|
|
171
|
+
// initial: PUBLISHING_ITEM,
|
|
172
|
+
},
|
|
173
|
+
[PUBLISHING_ITEM]: {
|
|
174
|
+
target: INITIALIZED,
|
|
175
|
+
entry: [
|
|
176
|
+
assign({
|
|
177
|
+
publishItemService: ({ spawn, event }) =>
|
|
178
|
+
spawn(publishMachine, {
|
|
179
|
+
id: 'publishService',
|
|
180
|
+
input: {
|
|
181
|
+
localId: event.seedLocalId,
|
|
182
|
+
},
|
|
176
183
|
}),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
}),
|
|
185
|
+
],
|
|
186
|
+
meta: {
|
|
187
|
+
displayText: 'Publishing item',
|
|
188
|
+
},
|
|
189
|
+
tags: ['publishing'],
|
|
190
|
+
},
|
|
191
|
+
savingPublishService: {
|
|
192
|
+
target: INITIALIZED,
|
|
193
|
+
on: {
|
|
194
|
+
savePublishServiceSuccess: INITIALIZED,
|
|
195
|
+
},
|
|
196
|
+
invoke: {
|
|
197
|
+
src: 'savePublishService',
|
|
198
|
+
input: ({ context }) => ({ context }),
|
|
199
|
+
},
|
|
200
|
+
meta: {
|
|
201
|
+
displayText: 'Saving publish service',
|
|
183
202
|
},
|
|
203
|
+
tags: ['publishing'],
|
|
184
204
|
},
|
|
185
205
|
},
|
|
186
206
|
// on: {
|
package/dist/src/index.ts
CHANGED
|
@@ -1,106 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FromCallbackInput } from '@/types/machines'
|
|
1
|
+
import { setup } from 'xstate'
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
versionLocalId,
|
|
23
|
-
versionUid,
|
|
24
|
-
propertyValue: existingValue,
|
|
25
|
-
propertyRecordSchema,
|
|
26
|
-
itemModelName,
|
|
27
|
-
schemaUid,
|
|
28
|
-
} = context
|
|
29
|
-
|
|
30
|
-
let newValue: ItemPropertyValueType
|
|
31
|
-
|
|
32
|
-
if (event) {
|
|
33
|
-
newValue = event.newValue
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (existingValue === newValue) {
|
|
37
|
-
sendBack({ type: 'saveValueToDbSuccess' })
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!propertyRecordSchema) {
|
|
42
|
-
throw new Error('Missing propertyRecordSchema')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const _analyzeInput = async (): Promise<boolean> => {
|
|
46
|
-
let propertyName = propertyNameRaw
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
propertyRecordSchema.refValueType &&
|
|
50
|
-
propertyRecordSchema.refValueType !== 'ImageSrc' &&
|
|
51
|
-
propertyRecordSchema.dataType === 'Relation'
|
|
52
|
-
) {
|
|
53
|
-
sendBack({
|
|
54
|
-
type: 'saveRelation',
|
|
55
|
-
newValue,
|
|
56
|
-
})
|
|
57
|
-
return false
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
propertyRecordSchema.refValueType === 'ImageSrc' ||
|
|
62
|
-
propertyRecordSchema.dataType === 'ImageSrc'
|
|
63
|
-
) {
|
|
64
|
-
sendBack({
|
|
65
|
-
type: 'saveImageSrc',
|
|
66
|
-
newValue,
|
|
67
|
-
})
|
|
68
|
-
return false
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
propertyRecordSchema.storageType &&
|
|
73
|
-
propertyRecordSchema.storageType === 'ItemStorage'
|
|
74
|
-
) {
|
|
75
|
-
sendBack({
|
|
76
|
-
type: 'saveItemStorage',
|
|
77
|
-
newValue,
|
|
78
|
-
})
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
await updateItemPropertyValue({
|
|
83
|
-
localId: localId,
|
|
84
|
-
propertyName,
|
|
85
|
-
newValue,
|
|
86
|
-
seedLocalId,
|
|
87
|
-
versionLocalId,
|
|
88
|
-
versionUid,
|
|
89
|
-
modelName: itemModelName,
|
|
90
|
-
schemaUid,
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
sendBack({
|
|
94
|
-
type: 'updateContext',
|
|
95
|
-
propertyValue: newValue,
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
return true
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
_analyzeInput().then((isDone) => {
|
|
102
|
-
if (isDone) {
|
|
103
|
-
sendBack({ type: 'saveValueToDbSuccess' })
|
|
104
|
-
}
|
|
105
|
-
})
|
|
3
|
+
uploadBinaryData,
|
|
4
|
+
uploadMetadata,
|
|
5
|
+
} from '@/browser/schema/file/upload/actors'
|
|
6
|
+
|
|
7
|
+
export const uploadMachine = setup({
|
|
8
|
+
actors: {
|
|
9
|
+
uploadBinaryData,
|
|
10
|
+
uploadMetadata,
|
|
11
|
+
},
|
|
12
|
+
}).createMachine({
|
|
13
|
+
id: 'upload',
|
|
14
|
+
initial: 'idle',
|
|
15
|
+
context: {
|
|
16
|
+
file: '',
|
|
17
|
+
},
|
|
18
|
+
states: {
|
|
19
|
+
idle: {},
|
|
20
|
+
},
|
|
106
21
|
})
|
package/dist/src/item.ts
CHANGED
|
@@ -335,10 +335,9 @@ type UsePublishItemReturn = {
|
|
|
335
335
|
isPublishing: boolean
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
type PublishItemProps =
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
]
|
|
338
|
+
type PublishItemProps =
|
|
339
|
+
| [Item<any> | undefined]
|
|
340
|
+
| [Item<any> | undefined, (result: PublishItemResult) => any | undefined]
|
|
342
341
|
|
|
343
342
|
type PublishItem = (...props: PublishItemProps) => Promise<any>
|
|
344
343
|
|
|
@@ -355,7 +354,8 @@ export const usePublishItem = (): UsePublishItemReturn => {
|
|
|
355
354
|
console.log('Publishing item', item)
|
|
356
355
|
setIsPublishing(true)
|
|
357
356
|
try {
|
|
358
|
-
await item.publish()
|
|
357
|
+
// await item.publish()
|
|
358
|
+
const payload = await item.getPublishPayload()
|
|
359
359
|
if (callback) {
|
|
360
360
|
callback()
|
|
361
361
|
}
|
package/dist/src/publish.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getGlobalService } from '@/browser/services/global'
|
|
2
2
|
|
|
3
3
|
type PublishItemRequestEvent = {
|
|
4
|
-
modelName?: string
|
|
5
4
|
seedLocalId: string
|
|
6
5
|
}
|
|
7
6
|
|
|
@@ -10,7 +9,6 @@ type PublishItemRequestHandler = (
|
|
|
10
9
|
) => Promise<void>
|
|
11
10
|
|
|
12
11
|
export const publishItemRequestHandler: PublishItemRequestHandler = async ({
|
|
13
|
-
modelName,
|
|
14
12
|
seedLocalId,
|
|
15
13
|
}) => {
|
|
16
14
|
const globalService = getGlobalService()
|
|
@@ -25,7 +23,6 @@ export const publishItemRequestHandler: PublishItemRequestHandler = async ({
|
|
|
25
23
|
})
|
|
26
24
|
globalService.send({
|
|
27
25
|
type: 'publishItemRequest',
|
|
28
|
-
modelName,
|
|
29
26
|
seedLocalId,
|
|
30
27
|
})
|
|
31
28
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getAppDb } from '@/browser'
|
|
2
|
+
import { appState } from '@/shared/seedSchema'
|
|
3
|
+
|
|
4
|
+
export const saveAppState = async (key: string, value: string) => {
|
|
5
|
+
const appDb = getAppDb()
|
|
6
|
+
|
|
7
|
+
await appDb
|
|
8
|
+
.insert(appState)
|
|
9
|
+
.values({
|
|
10
|
+
key,
|
|
11
|
+
value,
|
|
12
|
+
})
|
|
13
|
+
.onConflictDoUpdate({
|
|
14
|
+
target: appState.key,
|
|
15
|
+
set: {
|
|
16
|
+
value,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
+
import { FromCallbackInput, GlobalMachineContext } from '@/types/machines'
|
|
3
|
+
import { saveAppState } from '@/browser/db/write/saveAppState'
|
|
4
|
+
|
|
5
|
+
export const savePublishService = fromCallback<
|
|
6
|
+
EventObject,
|
|
7
|
+
FromCallbackInput<GlobalMachineContext>
|
|
8
|
+
>(({ sendBack, input: { event, context } }) => {
|
|
9
|
+
const { publishItemService } = context
|
|
10
|
+
|
|
11
|
+
if (!publishItemService) {
|
|
12
|
+
sendBack({ type: 'savePublishServiceError' })
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const _savePublishService = async (): Promise<boolean> => {
|
|
17
|
+
await saveAppState(
|
|
18
|
+
`snapshot__publishItemService`,
|
|
19
|
+
JSON.stringify(publishItemService.getPersistedSnapshot()),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_savePublishService().then((success) => {
|
|
26
|
+
if (success) {
|
|
27
|
+
sendBack({ type: 'savePublishServiceSuccess' })
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
package/dist/src/seed.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isBrowser, isNode, isReactNative } from '@/shared/environment'
|
|
2
|
+
import { Endpoints, SeedConstructorOptions } from '@/types/types'
|
|
3
|
+
import { Subject } from 'rxjs'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
type Environment = 'node' | 'browser' | 'react-native'
|
|
6
|
+
|
|
7
|
+
abstract class SeedBase {
|
|
8
|
+
private readonly _env: Environment = 'browser'
|
|
9
|
+
protected _subject: Subject<void> = new Subject<void>()
|
|
10
|
+
|
|
11
|
+
constructor(props: { endpoints: Endpoints }) {
|
|
12
|
+
console.log('Seed constructor called')
|
|
13
|
+
if (isNode()) {
|
|
14
|
+
this._env = 'node'
|
|
15
|
+
}
|
|
16
|
+
if (isBrowser()) {
|
|
17
|
+
this._env = 'browser'
|
|
18
|
+
}
|
|
19
|
+
if (isReactNative()) {
|
|
20
|
+
this._env = 'react-native'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async initialize() {}
|
|
25
|
+
|
|
26
|
+
subscribe(callback: (event: any) => void) {
|
|
27
|
+
return this._subject.subscribe(callback)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class SeedSync extends SeedBase {
|
|
5
32
|
constructor(props: SeedConstructorOptions) {
|
|
6
33
|
super(props)
|
|
7
34
|
}
|
|
8
35
|
}
|
|
9
36
|
|
|
10
|
-
export {
|
|
37
|
+
export { SeedBase, SeedSync }
|
package/dist/src/services.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { MachineIds } from '@/browser/services/internal/constants'
|
|
|
14
14
|
|
|
15
15
|
const logger = debug('app:react:services')
|
|
16
16
|
|
|
17
|
-
const finalStrings = ['idle', 'ready', 'done', 'success']
|
|
17
|
+
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized']
|
|
18
18
|
|
|
19
19
|
export const getServiceName = (service: ActorRef<any, any>) => {
|
|
20
20
|
let name = 'actor'
|
|
@@ -90,8 +90,17 @@ export const useService = (service: ActorRef<any, any>) => {
|
|
|
90
90
|
const getPercentComplete = (service: ActorRef<any, any>) => {
|
|
91
91
|
let percentComplete = 0
|
|
92
92
|
if (service.logic.states) {
|
|
93
|
-
const stateNames =
|
|
94
|
-
const
|
|
93
|
+
const stateNames = []
|
|
94
|
+
const startupStates = []
|
|
95
|
+
|
|
96
|
+
for (const [stateName, state] of Object.entries(service.logic.states)) {
|
|
97
|
+
if (state.tags.includes('loading')) {
|
|
98
|
+
stateNames.push(stateName)
|
|
99
|
+
startupStates.push(state)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const totalStates = startupStates.length
|
|
95
104
|
const value = getServiceValue(service)
|
|
96
105
|
if (finalStrings.includes(value)) {
|
|
97
106
|
return 0
|
|
@@ -311,7 +320,7 @@ export const useServices = () => {
|
|
|
311
320
|
return
|
|
312
321
|
}
|
|
313
322
|
if (
|
|
314
|
-
getServiceValue(globalService) === '
|
|
323
|
+
getServiceValue(globalService) === 'initialized' &&
|
|
315
324
|
getServiceValue(internalService) === 'ready'
|
|
316
325
|
) {
|
|
317
326
|
const denominator = actors.length
|