Software
Extension DP provides SDKs for Python and TypeScript/JavaScript to make it easy to publish and consume Extension Data Packages.
Python
Section titled “Python”Installation
Section titled “Installation”pip install extensiondp frictionlessPublication
Section titled “Publication”from extensiondp import Package, Table1, Table2import frictionless
# Create Table1 recordsrecord1 = Table1( id="t1-001", name="First Entity", status="active", value=100.5, itemCount=5, isVerified=True, createdDate="2024-01-15", description="This is the first example entity",)
# Create Table2 recordsrecord2 = Table2( id="t2-001", table1Id="t1-001", title="Related Item", amount=99.99, priority="high", percentage=75.5, notes="This item is related to the first entity", isActive=True,)
package = Package( { "$schema": "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/profile.json", "resources": [ { "name": "table1", "data": [record1], "schema": "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/schemas/table1.json", }, { "name": "table2", "data": [record2], "schema": "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/schemas/table2.json", }, ], })
frictionless.Package(package).to_json("extension.json")Validation
Section titled “Validation”import frictionless
report = frictionless.validate("extension.json")print(report)Consumption
Section titled “Consumption”import frictionless
package = frictionless.Package("extension.json")print(package)TypeScript
Section titled “TypeScript”Installation
Section titled “Installation”npm install extensiondp dpkitPublication
Section titled “Publication”import type { Table1, Table2, Package } from "extensiondp";import { savePackageDescriptor } from "dpkit";
const record1: Table1 = { id: "t1-001", name: "First Entity", status: "active", value: 100.5, itemCount: 5, isVerified: true, createdDate: "2024-01-15", description: "This is the first example entity",};
const record2: Table2 = { id: "t2-001", table1Id: "t1-001", title: "Related Item", amount: 99.99, priority: "high", percentage: 75.5, notes: "This item is related to the first entity", isActive: true,};
const dataPackage: Package = { $schema: "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/profile.json", resources: [ { name: "table1", data: [record1], schema: "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/schemas/table1.json", }, { name: "table2", data: [record2], schema: "https://raw.githubusercontent.com/datisthq/extensiondp/v0.1.0/extension/schemas/table2.json", }, ],};
await savePackageDescriptor(dataPackage, { path: "extension.json", overwrite: true,});Validation
Section titled “Validation”import { validatePackage } from "dpkit";
const { valid, errors } = await validatePackage("extension.json");console.log(valid, errors);Consumption
Section titled “Consumption”import { loadPackageDescriptor } from "dpkit";
const dataPackage = await loadPackageDescriptor("extension.json");console.log(dataPackage);Command-Line
Section titled “Command-Line”Installation
Section titled “Installation”curl -fsSL https://dpkit.dev/install.sh | shValidation
Section titled “Validation”./dp package validate extension.jsonConsumption
Section titled “Consumption”./dp table explore -p extension.json