@seedprotocol/sdk 0.1.7 → 0.1.8
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/bin.js +2 -2
- package/dist/{index-Bc3TXOPI.js → index-BeywvMUe.js} +2 -2
- package/dist/index-BeywvMUe.js.map +1 -0
- package/dist/{index-B8GMq1lE.js → index-Dg73YrcZ.js} +39 -12
- package/dist/index-Dg73YrcZ.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed-DoCPQNyp.js → seed-CACUpI2x.js} +2 -2
- package/dist/{seed-DoCPQNyp.js.map → seed-CACUpI2x.js.map} +1 -1
- package/dist/{seed-C7Q0_oW_.js → seed-Cqa2atpR.js} +3 -3
- package/dist/{seed-C7Q0_oW_.js.map → seed-Cqa2atpR.js.map} +1 -1
- package/dist/{seed-67gCBvdP.js → seed-CsQB9h6Q.js} +3 -3
- package/dist/{seed-67gCBvdP.js.map → seed-CsQB9h6Q.js.map} +1 -1
- package/dist/{seed.schema.config-Bq0uQNxG.js → seed.schema.config-CxqrGPwe.js} +2 -2
- package/dist/{seed.schema.config-Bq0uQNxG.js.map → seed.schema.config-CxqrGPwe.js.map} +1 -1
- package/dist/types/src/browser/db/read/getPropertiesForSeed.d.ts.map +1 -1
- package/dist/types/src/browser/item/class.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/react/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/index-B8GMq1lE.js.map +0 -1
- package/dist/index-Bc3TXOPI.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as __awaiter, D as DB_NAME_SDK_CONFIG, o as models, S as SCHEMA_NJK, p as SCHEMA_TS, q as SDK_DB_CONFIG, r as SEED_DB_CONFIG, A as APP_DB_CONFIG, s as addModelsToInternalDb } from './index-
|
|
2
|
+
import { n as __awaiter, D as DB_NAME_SDK_CONFIG, o as models, S as SCHEMA_NJK, p as SCHEMA_TS, q as SDK_DB_CONFIG, r as SEED_DB_CONFIG, A as APP_DB_CONFIG, s as addModelsToInternalDb } from './index-Dg73YrcZ.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import { exec as exec$1 } from 'child_process';
|
|
@@ -17,7 +17,7 @@ import { camelCase, snakeCase } from 'lodash-es';
|
|
|
17
17
|
import * as nunjucks from 'nunjucks';
|
|
18
18
|
import Database from 'better-sqlite3';
|
|
19
19
|
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
|
20
|
-
import './seed.schema.config-
|
|
20
|
+
import './seed.schema.config-CxqrGPwe.js';
|
|
21
21
|
import { defineConfig } from 'drizzle-kit';
|
|
22
22
|
import dotenv from 'dotenv';
|
|
23
23
|
import 'reflect-metadata';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, e as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SEEDS, b as GET_SEED_IDS, c as GET_STORAGE_TRANSACTION_ID, d as GET_VERSIONS, I as Item, g as itemMachineAll, i as itemMachineSingle } from './index-
|
|
1
|
+
export { f as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, e as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SEEDS, b as GET_SEED_IDS, c as GET_STORAGE_TRANSACTION_ID, d as GET_VERSIONS, I as Item, g as itemMachineAll, i as itemMachineSingle } from './index-Dg73YrcZ.js';
|
|
2
2
|
import 'path';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import '@sinclair/typebox';
|
|
@@ -26,4 +26,4 @@ import 'arweave';
|
|
|
26
26
|
import '@zenfs/dom';
|
|
27
27
|
import 'use-immer';
|
|
28
28
|
import '@xstate/react';
|
|
29
|
-
//# sourceMappingURL=index-
|
|
29
|
+
//# sourceMappingURL=index-BeywvMUe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BeywvMUe.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1650,17 +1650,24 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1650
1650
|
renderValue: refResolvedDisplayValue,
|
|
1651
1651
|
});
|
|
1652
1652
|
if (propertyNameFromDb === 'storageTransactionId') {
|
|
1653
|
-
const { Item } = yield import('./index-
|
|
1653
|
+
const { Item } = yield import('./index-BeywvMUe.js');
|
|
1654
1654
|
const item = yield Item.find({
|
|
1655
1655
|
seedLocalId,
|
|
1656
1656
|
modelName: itemModelName,
|
|
1657
1657
|
});
|
|
1658
1658
|
if (item) {
|
|
1659
1659
|
for (const [propertyName, property] of Object.entries(item.properties)) {
|
|
1660
|
-
if (propertyName === 'html'
|
|
1661
|
-
|
|
1660
|
+
if (propertyName === 'html' &&
|
|
1661
|
+
propertyValueFromDb &&
|
|
1662
|
+
propertyValueFromDb.length === 43) {
|
|
1663
|
+
const htmlFilePath = `/files/html/${propertyValueFromDb}.html`;
|
|
1664
|
+
const exists = yield fs.promises.exists(htmlFilePath);
|
|
1665
|
+
if (!exists) {
|
|
1666
|
+
logger$c(`HTML file does not exist for Property.${localId} at ${htmlFilePath}`);
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1662
1669
|
const renderValue = yield fs.promises
|
|
1663
|
-
.readFile(
|
|
1670
|
+
.readFile(htmlFilePath, 'utf8')
|
|
1664
1671
|
.catch((error) => {
|
|
1665
1672
|
logger$c('Error reading html file', error);
|
|
1666
1673
|
});
|
|
@@ -2116,7 +2123,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2116
2123
|
if (!models$1) {
|
|
2117
2124
|
return;
|
|
2118
2125
|
}
|
|
2119
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2126
|
+
const { models: SeedModels } = yield import('./seed.schema.config-CxqrGPwe.js');
|
|
2120
2127
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2121
2128
|
let hasModelsInDb = false;
|
|
2122
2129
|
const schemaDefsByModelName = new Map();
|
|
@@ -4236,11 +4243,11 @@ const globalMachine = setup({
|
|
|
4236
4243
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
4237
4244
|
let SeedClass;
|
|
4238
4245
|
if (context.environment === 'node') {
|
|
4239
|
-
const { SeedNode } = yield import('./seed-
|
|
4246
|
+
const { SeedNode } = yield import('./seed-CsQB9h6Q.js');
|
|
4240
4247
|
SeedClass = SeedNode;
|
|
4241
4248
|
}
|
|
4242
4249
|
else {
|
|
4243
|
-
const { SeedBrowser } = yield import('./seed-
|
|
4250
|
+
const { SeedBrowser } = yield import('./seed-Cqa2atpR.js');
|
|
4244
4251
|
SeedClass = SeedBrowser;
|
|
4245
4252
|
}
|
|
4246
4253
|
return SeedClass;
|
|
@@ -5214,6 +5221,19 @@ const itemMachineSingle = setup({
|
|
|
5214
5221
|
});
|
|
5215
5222
|
|
|
5216
5223
|
const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5224
|
+
if (seedLocalId && !seedUid) {
|
|
5225
|
+
const seedQueryStatement = `SELECT uid
|
|
5226
|
+
FROM seeds
|
|
5227
|
+
WHERE local_id = '${seedLocalId}';`;
|
|
5228
|
+
const { rows } = yield runQueryForStatement(seedQueryStatement);
|
|
5229
|
+
if (rows && rows.length > 0) {
|
|
5230
|
+
seedUid = rows[0][0];
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
const localIdWhere = seedLocalId
|
|
5234
|
+
? `s.local_id = '${seedLocalId}'`
|
|
5235
|
+
: 's.local_id IS NULL';
|
|
5236
|
+
const uidWhere = seedUid ? `s.uid = '${seedUid}'` : 's.uid IS NULL';
|
|
5217
5237
|
const queryStatement = `WITH LatestMetadata as (SELECT m.property_name,
|
|
5218
5238
|
m.property_value,
|
|
5219
5239
|
m.version_local_id,
|
|
@@ -5224,6 +5244,7 @@ const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0,
|
|
|
5224
5244
|
FROM metadata m
|
|
5225
5245
|
JOIN seeds s ON s.local_id = m.seed_local_id
|
|
5226
5246
|
GROUP BY m.property_name),
|
|
5247
|
+
|
|
5227
5248
|
LatestVersion as (SELECT v.local_id,
|
|
5228
5249
|
MAX(v.attestation_created_at) as attestation_created_at,
|
|
5229
5250
|
v.uid,
|
|
@@ -5233,6 +5254,7 @@ const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0,
|
|
|
5233
5254
|
JOIN seeds s ON s.local_id = v.seed_local_id
|
|
5234
5255
|
GROUP BY s.local_id)
|
|
5235
5256
|
|
|
5257
|
+
|
|
5236
5258
|
SELECT s.local_id,
|
|
5237
5259
|
s.uid,
|
|
5238
5260
|
s.schema_uid,
|
|
@@ -5255,8 +5277,8 @@ const getPropertiesForSeed = (seedLocalId, seedUid) => __awaiter(void 0, void 0,
|
|
|
5255
5277
|
JOIN LatestVersion lv ON lv.seed_local_id = m.seed_local_id
|
|
5256
5278
|
JOIN metadata m ON m.property_name = lm.property_name OR lm.property_value = s.uid
|
|
5257
5279
|
JOIN versions v ON s.local_id = v.seed_local_id
|
|
5258
|
-
WHERE
|
|
5259
|
-
OR
|
|
5280
|
+
WHERE ${localIdWhere}
|
|
5281
|
+
OR ${uidWhere}
|
|
5260
5282
|
GROUP BY m.property_name;
|
|
5261
5283
|
`;
|
|
5262
5284
|
const { rows } = yield runQueryForStatement(queryStatement);
|
|
@@ -5438,6 +5460,7 @@ class Item {
|
|
|
5438
5460
|
propertiesObj[transformedKey] = propertyInstance;
|
|
5439
5461
|
}
|
|
5440
5462
|
this._propertiesSubject.next(propertiesObj);
|
|
5463
|
+
eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`);
|
|
5441
5464
|
});
|
|
5442
5465
|
this._service.start();
|
|
5443
5466
|
const definedKeys = ['ModelClass'];
|
|
@@ -5746,7 +5769,11 @@ const useItems = ({ modelName, options }) => {
|
|
|
5746
5769
|
};
|
|
5747
5770
|
}, []);
|
|
5748
5771
|
return {
|
|
5749
|
-
items: orderBy(items, [
|
|
5772
|
+
items: orderBy(items, [
|
|
5773
|
+
(item) => item.lastVersionPublishedAt ||
|
|
5774
|
+
item.attestationCreatedAt ||
|
|
5775
|
+
item.createdAt,
|
|
5776
|
+
], ['desc']),
|
|
5750
5777
|
isReadingDb,
|
|
5751
5778
|
isInitialized,
|
|
5752
5779
|
refresh,
|
|
@@ -6794,7 +6821,7 @@ const client = {
|
|
|
6794
6821
|
console.error('fs listeners not ready during init');
|
|
6795
6822
|
}
|
|
6796
6823
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6797
|
-
import('./seed.schema.config-
|
|
6824
|
+
import('./seed.schema.config-CxqrGPwe.js').then(({ models }) => {
|
|
6798
6825
|
for (const [key, value] of Object.entries(models)) {
|
|
6799
6826
|
modelStore.set(key, value);
|
|
6800
6827
|
}
|
|
@@ -6852,4 +6879,4 @@ const client = {
|
|
|
6852
6879
|
};
|
|
6853
6880
|
|
|
6854
6881
|
export { APP_DB_CONFIG as A, useCreateItem as B, CHILD_SNAPSHOT as C, DB_NAME_SDK_CONFIG as D, useItemProperty as E, useDeleteItem as F, GET_SCHEMAS as G, getGlobalService as H, Item as I, Json as J, getCorrectId as K, List as L, Model as M, Property as P, Relation as R, SCHEMA_NJK as S, Text as T, __decorate as _, GET_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, __metadata as h, itemMachineSingle as i, internalMachine as j, isNode as k, isBrowser as l, isReactNative as m, __awaiter as n, models as o, SCHEMA_TS as p, SDK_DB_CONFIG as q, SEED_DB_CONFIG as r, addModelsToInternalDb as s, client as t, ImageSrc as u, ItemProperty as v, withSeed as w, useItems as x, useItem as y, useItemProperties as z };
|
|
6855
|
-
//# sourceMappingURL=index-
|
|
6882
|
+
//# sourceMappingURL=index-Dg73YrcZ.js.map
|