1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

using files intead of contentUrls on examples ocean#251

This commit is contained in:
Pedro Gutiérrez 2019-02-06 13:37:31 +01:00 committed by Pedro Gutiérrez
parent e88a40dac0
commit c56989a710
10 changed files with 73 additions and 32 deletions

View File

@ -13,7 +13,7 @@ async function exec() {
publisher.setPassword(process.env.ACCOUNT_PASSWORD) publisher.setPassword(process.env.ACCOUNT_PASSWORD)
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData: Partial<MetaData> = <any> { const metaData: Partial<MetaData> = {
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -28,9 +28,15 @@ async function exec() {
contentType: "text/csv", contentType: "text/csv",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -12,7 +12,7 @@ async function exec() {
publisher.setPassword(process.env.ACCOUNT_PASSWORD) publisher.setPassword(process.env.ACCOUNT_PASSWORD)
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData: Partial<MetaData> = <any> { const metaData: Partial<MetaData> = {
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -27,9 +27,15 @@ async function exec() {
contentType: "text/csv", contentType: "text/csv",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -13,7 +13,7 @@ async function exec() {
publisher.setPassword(process.env.ACCOUNT_PASSWORD) publisher.setPassword(process.env.ACCOUNT_PASSWORD)
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData: Partial<MetaData> = <any> { const metaData: Partial<MetaData> = {
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -28,9 +28,15 @@ async function exec() {
contentType: "text/csv", contentType: "text/csv",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -11,7 +11,7 @@ async function exec() {
const publisher: Account = (await ocean.getAccounts())[1] const publisher: Account = (await ocean.getAccounts())[1]
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData: Partial<MetaData> = <any> { const metaData: Partial<MetaData> = {
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -26,8 +26,15 @@ async function exec() {
contentType: "Application/pdf", contentType: "Application/pdf",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.pdf", {
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -10,7 +10,7 @@ async function exec() {
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
publisher.setPassword(process.env.ACCOUNT_PASSWORD) publisher.setPassword(process.env.ACCOUNT_PASSWORD)
const metaData: Partial<MetaData> = <any> { const metaData: Partial<MetaData> = {
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -25,9 +25,15 @@ async function exec() {
contentType: "text/csv", contentType: "text/csv",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -26,7 +26,7 @@ async function exec() {
updateFrecuency: "yearly", updateFrecuency: "yearly",
checksum: "efdd14d39feb726e321931f408b3454d26f1a4899bcc608a68b5397f23203174", checksum: "efdd14d39feb726e321931f408b3454d26f1a4899bcc608a68b5397f23203174",
}, },
base: <any> { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
description: "Weather information of UK including temperature and humidity", description: "Weather information of UK including temperature and humidity",
@ -40,9 +40,15 @@ async function exec() {
contentType: "text/csv", contentType: "text/csv",
// tslint:disable-next-line // tslint:disable-next-line
workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "stationId,latitude,longitude,datetime,temperature,humidity423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"}, {sample1: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"},

View File

@ -181,7 +181,7 @@ export default class Ocean {
Logger.log("Awesome; got a AccessGranted Event. Let's download the asset files.") Logger.log("Awesome; got a AccessGranted Event. Let's download the asset files.")
const contentUrls = await SecretStoreProvider const contentUrls = await SecretStoreProvider
.getSecretStore() .getSecretStore()
.decryptDocument(d.getId(), metadataService.metadata.base.contentUrls[0]) .decryptDocument(d.getId(), (metadataService as any).metadata.base.contentUrls[0])
const serviceUrl: string = accessService.serviceEndpoint const serviceUrl: string = accessService.serviceEndpoint
Logger.log("Consuming asset files using service url: ", serviceUrl) Logger.log("Consuming asset files using service url: ", serviceUrl)
const files = [] const files = []

View File

@ -144,8 +144,9 @@ export default class OceanAssets {
// Cleaning not needed information // Cleaning not needed information
base: { base: {
...metadata.base, ...metadata.base,
contentUrls: [],
files: undefined, files: undefined,
}, } as any,
}, },
}, },
], ],

View File

@ -226,9 +226,7 @@ export default class ServiceAgreement extends OceanBase {
await token.approve(paymentConditions.getAddress(), price, consumer.getId()) await token.approve(paymentConditions.getAddress(), price, consumer.getId())
const lockPaymentReceipt = const lockPaymentReceipt = await paymentConditions.lockPayment(this.getId(), assetId, price, consumer.getId())
await paymentConditions.lockPayment(this.getId(), assetId, price,
consumer.getId())
return lockPaymentReceipt.status return lockPaymentReceipt.status
} }

View File

@ -14,9 +14,15 @@ export const metadataMock: MetaData = {
compression: "zip", compression: "zip",
contentType: "text/csv", contentType: "text/csv",
workExample: "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68", workExample: "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68",
contentUrls: [ files: [
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", {
"https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip", url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip",
checksum: "085340abffh21495345af97c6b0e761",
contentLength: "12324",
},
{
url: "https://testocnfiles.blob.core.windows.net/testfiles/testzkp2.zip",
},
], ],
links: [ links: [
{ {
@ -34,7 +40,6 @@ export const metadataMock: MetaData = {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
files: [],
checksum: "", checksum: "",
}, },
curation: { curation: {