@originals/sdk 1.4.3 → 1.4.5
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/adapters/FeeOracleMock.d.ts +6 -0
- package/dist/adapters/FeeOracleMock.js +8 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/providers/OrdHttpProvider.d.ts +56 -0
- package/dist/adapters/providers/OrdHttpProvider.js +110 -0
- package/dist/adapters/providers/OrdMockProvider.d.ts +70 -0
- package/dist/adapters/providers/OrdMockProvider.js +75 -0
- package/dist/adapters/types.d.ts +71 -0
- package/dist/adapters/types.js +1 -0
- package/dist/bitcoin/BitcoinManager.d.ts +15 -0
- package/dist/bitcoin/BitcoinManager.js +262 -0
- package/dist/bitcoin/BroadcastClient.d.ts +30 -0
- package/dist/bitcoin/BroadcastClient.js +35 -0
- package/dist/bitcoin/OrdinalsClient.d.ts +21 -0
- package/dist/bitcoin/OrdinalsClient.js +105 -0
- package/dist/bitcoin/PSBTBuilder.d.ts +24 -0
- package/dist/bitcoin/PSBTBuilder.js +80 -0
- package/dist/bitcoin/fee-calculation.d.ts +14 -0
- package/dist/bitcoin/fee-calculation.js +31 -0
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +38 -0
- package/dist/bitcoin/providers/OrdNodeProvider.js +67 -0
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +33 -0
- package/dist/bitcoin/providers/OrdinalsProvider.js +50 -0
- package/dist/bitcoin/providers/types.d.ts +63 -0
- package/dist/bitcoin/providers/types.js +1 -0
- package/dist/bitcoin/transactions/commit.d.ts +89 -0
- package/dist/bitcoin/transactions/commit.js +311 -0
- package/dist/bitcoin/transactions/index.d.ts +7 -0
- package/dist/bitcoin/transactions/index.js +8 -0
- package/dist/bitcoin/transfer.d.ts +9 -0
- package/dist/bitcoin/transfer.js +26 -0
- package/dist/bitcoin/utxo-selection.d.ts +78 -0
- package/dist/bitcoin/utxo-selection.js +237 -0
- package/dist/bitcoin/utxo.d.ts +26 -0
- package/dist/bitcoin/utxo.js +78 -0
- package/dist/contexts/credentials-v1.json +195 -0
- package/dist/contexts/credentials-v2-examples.json +5 -0
- package/dist/contexts/credentials-v2.json +301 -0
- package/dist/contexts/credentials.json +195 -0
- package/dist/contexts/data-integrity-v2.json +81 -0
- package/dist/contexts/dids.json +57 -0
- package/dist/contexts/ed255192020.json +93 -0
- package/dist/contexts/ordinals-plus.json +23 -0
- package/dist/contexts/originals.json +22 -0
- package/dist/core/OriginalsSDK.d.ts +158 -0
- package/dist/core/OriginalsSDK.js +274 -0
- package/dist/crypto/Multikey.d.ts +30 -0
- package/dist/crypto/Multikey.js +149 -0
- package/dist/crypto/Signer.d.ts +21 -0
- package/dist/crypto/Signer.js +196 -0
- package/dist/crypto/noble-init.d.ts +18 -0
- package/dist/crypto/noble-init.js +106 -0
- package/dist/did/BtcoDidResolver.d.ts +57 -0
- package/dist/did/BtcoDidResolver.js +166 -0
- package/dist/did/DIDManager.d.ts +101 -0
- package/dist/did/DIDManager.js +493 -0
- package/dist/did/Ed25519Verifier.d.ts +30 -0
- package/dist/did/Ed25519Verifier.js +59 -0
- package/dist/did/KeyManager.d.ts +17 -0
- package/dist/did/KeyManager.js +207 -0
- package/dist/did/WebVHManager.d.ts +100 -0
- package/dist/did/WebVHManager.js +312 -0
- package/dist/did/createBtcoDidDocument.d.ts +10 -0
- package/dist/did/createBtcoDidDocument.js +42 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +23 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +51 -0
- package/dist/events/EventEmitter.d.ts +115 -0
- package/dist/events/EventEmitter.js +198 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.js +6 -0
- package/dist/events/types.d.ts +286 -0
- package/dist/events/types.js +9 -0
- package/dist/examples/basic-usage.d.ts +3 -0
- package/dist/examples/basic-usage.js +62 -0
- package/dist/examples/create-module-original.d.ts +32 -0
- package/dist/examples/create-module-original.js +376 -0
- package/dist/examples/full-lifecycle-flow.d.ts +56 -0
- package/dist/examples/full-lifecycle-flow.js +419 -0
- package/dist/examples/run.d.ts +12 -0
- package/dist/examples/run.js +51 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +52 -0
- package/dist/kinds/KindRegistry.d.ts +76 -0
- package/dist/kinds/KindRegistry.js +216 -0
- package/dist/kinds/index.d.ts +33 -0
- package/dist/kinds/index.js +36 -0
- package/dist/kinds/types.d.ts +363 -0
- package/dist/kinds/types.js +25 -0
- package/dist/kinds/validators/AgentValidator.d.ts +14 -0
- package/dist/kinds/validators/AgentValidator.js +155 -0
- package/dist/kinds/validators/AppValidator.d.ts +14 -0
- package/dist/kinds/validators/AppValidator.js +135 -0
- package/dist/kinds/validators/DatasetValidator.d.ts +14 -0
- package/dist/kinds/validators/DatasetValidator.js +148 -0
- package/dist/kinds/validators/DocumentValidator.d.ts +14 -0
- package/dist/kinds/validators/DocumentValidator.js +180 -0
- package/dist/kinds/validators/MediaValidator.d.ts +14 -0
- package/dist/kinds/validators/MediaValidator.js +172 -0
- package/dist/kinds/validators/ModuleValidator.d.ts +14 -0
- package/dist/kinds/validators/ModuleValidator.js +140 -0
- package/dist/kinds/validators/base.d.ts +96 -0
- package/dist/kinds/validators/base.js +218 -0
- package/dist/kinds/validators/index.d.ts +10 -0
- package/dist/kinds/validators/index.js +10 -0
- package/dist/lifecycle/BatchOperations.d.ts +147 -0
- package/dist/lifecycle/BatchOperations.js +251 -0
- package/dist/lifecycle/LifecycleManager.d.ts +362 -0
- package/dist/lifecycle/LifecycleManager.js +1692 -0
- package/dist/lifecycle/OriginalsAsset.d.ts +164 -0
- package/dist/lifecycle/OriginalsAsset.js +380 -0
- package/dist/lifecycle/ProvenanceQuery.d.ts +126 -0
- package/dist/lifecycle/ProvenanceQuery.js +220 -0
- package/dist/lifecycle/ResourceVersioning.d.ts +73 -0
- package/dist/lifecycle/ResourceVersioning.js +127 -0
- package/dist/migration/MigrationManager.d.ts +86 -0
- package/dist/migration/MigrationManager.js +412 -0
- package/dist/migration/audit/AuditLogger.d.ts +51 -0
- package/dist/migration/audit/AuditLogger.js +156 -0
- package/dist/migration/checkpoint/CheckpointManager.d.ts +31 -0
- package/dist/migration/checkpoint/CheckpointManager.js +96 -0
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +26 -0
- package/dist/migration/checkpoint/CheckpointStorage.js +89 -0
- package/dist/migration/index.d.ts +22 -0
- package/dist/migration/index.js +27 -0
- package/dist/migration/operations/BaseMigration.d.ts +48 -0
- package/dist/migration/operations/BaseMigration.js +83 -0
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/PeerToBtcoMigration.js +67 -0
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +19 -0
- package/dist/migration/operations/PeerToWebvhMigration.js +46 -0
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/WebvhToBtcoMigration.js +67 -0
- package/dist/migration/rollback/RollbackManager.d.ts +29 -0
- package/dist/migration/rollback/RollbackManager.js +146 -0
- package/dist/migration/state/StateMachine.d.ts +25 -0
- package/dist/migration/state/StateMachine.js +76 -0
- package/dist/migration/state/StateTracker.d.ts +36 -0
- package/dist/migration/state/StateTracker.js +123 -0
- package/dist/migration/types.d.ts +306 -0
- package/dist/migration/types.js +33 -0
- package/dist/migration/validation/BitcoinValidator.d.ts +13 -0
- package/dist/migration/validation/BitcoinValidator.js +83 -0
- package/dist/migration/validation/CredentialValidator.d.ts +13 -0
- package/dist/migration/validation/CredentialValidator.js +46 -0
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +16 -0
- package/dist/migration/validation/DIDCompatibilityValidator.js +127 -0
- package/dist/migration/validation/LifecycleValidator.d.ts +10 -0
- package/dist/migration/validation/LifecycleValidator.js +52 -0
- package/dist/migration/validation/StorageValidator.d.ts +10 -0
- package/dist/migration/validation/StorageValidator.js +65 -0
- package/dist/migration/validation/ValidationPipeline.d.ts +29 -0
- package/dist/migration/validation/ValidationPipeline.js +180 -0
- package/dist/resources/ResourceManager.d.ts +231 -0
- package/dist/resources/ResourceManager.js +573 -0
- package/dist/resources/index.d.ts +11 -0
- package/dist/resources/index.js +10 -0
- package/dist/resources/types.d.ts +93 -0
- package/dist/resources/types.js +80 -0
- package/dist/storage/LocalStorageAdapter.d.ts +11 -0
- package/dist/storage/LocalStorageAdapter.js +53 -0
- package/dist/storage/MemoryStorageAdapter.d.ts +6 -0
- package/dist/storage/MemoryStorageAdapter.js +21 -0
- package/dist/storage/StorageAdapter.d.ts +16 -0
- package/dist/storage/StorageAdapter.js +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/types/bitcoin.d.ts +84 -0
- package/dist/types/bitcoin.js +1 -0
- package/dist/types/common.d.ts +82 -0
- package/dist/types/common.js +1 -0
- package/dist/types/credentials.d.ts +75 -0
- package/dist/types/credentials.js +1 -0
- package/dist/types/did.d.ts +26 -0
- package/dist/types/did.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/network.d.ts +78 -0
- package/dist/types/network.js +145 -0
- package/dist/utils/EventLogger.d.ts +71 -0
- package/dist/utils/EventLogger.js +232 -0
- package/dist/utils/Logger.d.ts +106 -0
- package/dist/utils/Logger.js +257 -0
- package/dist/utils/MetricsCollector.d.ts +110 -0
- package/dist/utils/MetricsCollector.js +264 -0
- package/dist/utils/bitcoin-address.d.ts +38 -0
- package/dist/utils/bitcoin-address.js +113 -0
- package/dist/utils/cbor.d.ts +2 -0
- package/dist/utils/cbor.js +9 -0
- package/dist/utils/encoding.d.ts +37 -0
- package/dist/utils/encoding.js +120 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/retry.d.ts +10 -0
- package/dist/utils/retry.js +35 -0
- package/dist/utils/satoshi-validation.d.ts +60 -0
- package/dist/utils/satoshi-validation.js +156 -0
- package/dist/utils/serialization.d.ts +14 -0
- package/dist/utils/serialization.js +76 -0
- package/dist/utils/telemetry.d.ts +17 -0
- package/dist/utils/telemetry.js +24 -0
- package/dist/utils/validation.d.ts +5 -0
- package/dist/utils/validation.js +98 -0
- package/dist/vc/CredentialManager.d.ts +329 -0
- package/dist/vc/CredentialManager.js +615 -0
- package/dist/vc/Issuer.d.ts +27 -0
- package/dist/vc/Issuer.js +70 -0
- package/dist/vc/Verifier.d.ts +16 -0
- package/dist/vc/Verifier.js +50 -0
- package/dist/vc/cryptosuites/bbs.d.ts +44 -0
- package/dist/vc/cryptosuites/bbs.js +213 -0
- package/dist/vc/cryptosuites/bbsSimple.d.ts +9 -0
- package/dist/vc/cryptosuites/bbsSimple.js +12 -0
- package/dist/vc/cryptosuites/eddsa.d.ts +30 -0
- package/dist/vc/cryptosuites/eddsa.js +81 -0
- package/dist/vc/documentLoader.d.ts +16 -0
- package/dist/vc/documentLoader.js +59 -0
- package/dist/vc/proofs/data-integrity.d.ts +21 -0
- package/dist/vc/proofs/data-integrity.js +15 -0
- package/dist/vc/utils/jsonld.d.ts +2 -0
- package/dist/vc/utils/jsonld.js +15 -0
- package/package.json +2 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kind Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for Original kinds, providing validation and type management.
|
|
5
|
+
*/
|
|
6
|
+
import { OriginalKind, } from './types';
|
|
7
|
+
import { ValidationUtils, AppValidator, AgentValidator, ModuleValidator, DatasetValidator, MediaValidator, DocumentValidator, } from './validators';
|
|
8
|
+
/**
|
|
9
|
+
* Registry for Original kinds
|
|
10
|
+
*
|
|
11
|
+
* Provides centralized validation and type information for all kinds.
|
|
12
|
+
*/
|
|
13
|
+
export class KindRegistry {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.validators = new Map();
|
|
16
|
+
this.registerDefaultValidators();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the singleton instance
|
|
20
|
+
*/
|
|
21
|
+
static getInstance() {
|
|
22
|
+
if (!KindRegistry.instance) {
|
|
23
|
+
KindRegistry.instance = new KindRegistry();
|
|
24
|
+
}
|
|
25
|
+
return KindRegistry.instance;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Register default validators for all built-in kinds
|
|
29
|
+
*/
|
|
30
|
+
registerDefaultValidators() {
|
|
31
|
+
this.validators.set(OriginalKind.App, new AppValidator());
|
|
32
|
+
this.validators.set(OriginalKind.Agent, new AgentValidator());
|
|
33
|
+
this.validators.set(OriginalKind.Module, new ModuleValidator());
|
|
34
|
+
this.validators.set(OriginalKind.Dataset, new DatasetValidator());
|
|
35
|
+
this.validators.set(OriginalKind.Media, new MediaValidator());
|
|
36
|
+
this.validators.set(OriginalKind.Document, new DocumentValidator());
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Register a custom validator for a kind
|
|
40
|
+
* Can be used to override built-in validators or add new kinds
|
|
41
|
+
*/
|
|
42
|
+
registerValidator(kind, validator) {
|
|
43
|
+
this.validators.set(kind, validator);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the validator for a kind
|
|
47
|
+
*/
|
|
48
|
+
getValidator(kind) {
|
|
49
|
+
return this.validators.get(kind);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if a kind is registered
|
|
53
|
+
*/
|
|
54
|
+
hasKind(kind) {
|
|
55
|
+
return this.validators.has(kind);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all registered kinds
|
|
59
|
+
*/
|
|
60
|
+
getRegisteredKinds() {
|
|
61
|
+
return Array.from(this.validators.keys());
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Validate a manifest
|
|
65
|
+
*
|
|
66
|
+
* @param manifest - The manifest to validate
|
|
67
|
+
* @param options - Validation options
|
|
68
|
+
* @returns Validation result
|
|
69
|
+
*/
|
|
70
|
+
validate(manifest, options) {
|
|
71
|
+
// First check if kind is valid
|
|
72
|
+
if (!manifest.kind) {
|
|
73
|
+
return ValidationUtils.failure([
|
|
74
|
+
ValidationUtils.error('MISSING_KIND', 'Manifest must specify a kind', 'kind'),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
// Check if kind is registered
|
|
78
|
+
if (!this.hasKind(manifest.kind)) {
|
|
79
|
+
return ValidationUtils.failure([
|
|
80
|
+
ValidationUtils.error('UNKNOWN_KIND', `Unknown kind: "${manifest.kind}". Registered kinds: ${this.getRegisteredKinds().join(', ')}`, 'kind', manifest.kind),
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
// Get validator and run validation
|
|
84
|
+
const validator = this.getValidator(manifest.kind);
|
|
85
|
+
if (!validator) {
|
|
86
|
+
return ValidationUtils.failure([
|
|
87
|
+
ValidationUtils.error('VALIDATOR_NOT_FOUND', `No validator found for kind: ${manifest.kind}`, 'kind'),
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
const result = validator.validate(manifest);
|
|
91
|
+
// In strict mode, treat warnings as errors
|
|
92
|
+
if (options?.strictMode && result.warnings.length > 0) {
|
|
93
|
+
const warningErrors = result.warnings.map(w => ValidationUtils.error(`STRICT_${w.code}`, `[Warning treated as error] ${w.message}`, w.path));
|
|
94
|
+
return ValidationUtils.failure([...result.errors, ...warningErrors], []);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Validate a manifest and throw if invalid
|
|
100
|
+
*/
|
|
101
|
+
validateOrThrow(manifest, options) {
|
|
102
|
+
if (options?.skipValidation) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const result = this.validate(manifest, options);
|
|
106
|
+
if (!result.isValid) {
|
|
107
|
+
const errorMessages = result.errors.map(e => {
|
|
108
|
+
const path = e.path ? ` at ${e.path}` : '';
|
|
109
|
+
return `[${e.code}]${path}: ${e.message}`;
|
|
110
|
+
});
|
|
111
|
+
throw new Error(`Manifest validation failed:\n${errorMessages.join('\n')}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if a value is a valid OriginalKind
|
|
116
|
+
*/
|
|
117
|
+
static isValidKind(value) {
|
|
118
|
+
return typeof value === 'string' && Object.values(OriginalKind).includes(value);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Parse a kind string to OriginalKind
|
|
122
|
+
* Accepts both full URIs (originals:kind:app) and short names (app)
|
|
123
|
+
*/
|
|
124
|
+
static parseKind(value) {
|
|
125
|
+
// Check if it's already a full kind URI
|
|
126
|
+
if (KindRegistry.isValidKind(value)) {
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
// Try to match short name
|
|
130
|
+
const normalized = value.toLowerCase().trim();
|
|
131
|
+
for (const kind of Object.values(OriginalKind)) {
|
|
132
|
+
const shortName = kind.split(':').pop()?.toLowerCase();
|
|
133
|
+
if (shortName === normalized) {
|
|
134
|
+
return kind;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get the short name of a kind (e.g., "app" from "originals:kind:app")
|
|
141
|
+
*/
|
|
142
|
+
static getShortName(kind) {
|
|
143
|
+
return kind.split(':').pop() || kind;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get human-readable display name for a kind
|
|
147
|
+
*/
|
|
148
|
+
static getDisplayName(kind) {
|
|
149
|
+
const shortName = KindRegistry.getShortName(kind);
|
|
150
|
+
return shortName.charAt(0).toUpperCase() + shortName.slice(1);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create an empty manifest template for a kind
|
|
154
|
+
* Useful for scaffolding new Originals
|
|
155
|
+
*/
|
|
156
|
+
static createTemplate(kind, name, version = '1.0.0') {
|
|
157
|
+
const base = {
|
|
158
|
+
kind,
|
|
159
|
+
name,
|
|
160
|
+
version,
|
|
161
|
+
resources: [],
|
|
162
|
+
};
|
|
163
|
+
// Add kind-specific metadata templates
|
|
164
|
+
switch (kind) {
|
|
165
|
+
case OriginalKind.App:
|
|
166
|
+
return {
|
|
167
|
+
...base,
|
|
168
|
+
metadata: {
|
|
169
|
+
runtime: 'node',
|
|
170
|
+
entrypoint: 'index.js',
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
case OriginalKind.Agent:
|
|
174
|
+
return {
|
|
175
|
+
...base,
|
|
176
|
+
metadata: {
|
|
177
|
+
capabilities: [],
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
case OriginalKind.Module:
|
|
181
|
+
return {
|
|
182
|
+
...base,
|
|
183
|
+
metadata: {
|
|
184
|
+
format: 'esm',
|
|
185
|
+
main: 'index.js',
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
case OriginalKind.Dataset:
|
|
189
|
+
return {
|
|
190
|
+
...base,
|
|
191
|
+
metadata: {
|
|
192
|
+
format: 'json',
|
|
193
|
+
schema: {},
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
case OriginalKind.Media:
|
|
197
|
+
return {
|
|
198
|
+
...base,
|
|
199
|
+
metadata: {
|
|
200
|
+
mediaType: 'image',
|
|
201
|
+
mimeType: 'image/png',
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
case OriginalKind.Document:
|
|
205
|
+
return {
|
|
206
|
+
...base,
|
|
207
|
+
metadata: {
|
|
208
|
+
format: 'markdown',
|
|
209
|
+
content: 'content',
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
default:
|
|
213
|
+
return base;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Originals Kind System
|
|
3
|
+
*
|
|
4
|
+
* Provides typed "Kinds" for Originals - a classification system that
|
|
5
|
+
* enables kind-specific validation, metadata schemas, and behaviors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { OriginalKind, KindRegistry } from '@originals/sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Create an App Original manifest
|
|
12
|
+
* const appManifest = {
|
|
13
|
+
* kind: OriginalKind.App,
|
|
14
|
+
* name: 'MyApp',
|
|
15
|
+
* version: '1.0.0',
|
|
16
|
+
* resources: [entrypointResource],
|
|
17
|
+
* metadata: {
|
|
18
|
+
* runtime: 'node',
|
|
19
|
+
* entrypoint: 'index.js',
|
|
20
|
+
* },
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* // Validate the manifest
|
|
24
|
+
* const registry = KindRegistry.getInstance();
|
|
25
|
+
* const result = registry.validate(appManifest);
|
|
26
|
+
* if (!result.isValid) {
|
|
27
|
+
* console.error('Validation errors:', result.errors);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export { OriginalKind, type DependencyRef, type BaseManifest, type AppMetadata, type AgentMetadata, type ModuleMetadata, type DatasetMetadata, type MediaMetadata, type DocumentMetadata, type KindMetadataMap, type KindMetadata, type OriginalManifest, type AppManifest, type AgentManifest, type ModuleManifest, type DatasetManifest, type MediaManifest, type DocumentManifest, type AnyManifest, type ValidationResult, type ValidationError, type ValidationWarning, type CreateTypedOriginalOptions, } from './types';
|
|
32
|
+
export { KindRegistry } from './KindRegistry';
|
|
33
|
+
export { type KindValidator, BaseKindValidator, ValidationUtils, AppValidator, AgentValidator, ModuleValidator, DatasetValidator, MediaValidator, DocumentValidator, } from './validators';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Originals Kind System
|
|
3
|
+
*
|
|
4
|
+
* Provides typed "Kinds" for Originals - a classification system that
|
|
5
|
+
* enables kind-specific validation, metadata schemas, and behaviors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { OriginalKind, KindRegistry } from '@originals/sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Create an App Original manifest
|
|
12
|
+
* const appManifest = {
|
|
13
|
+
* kind: OriginalKind.App,
|
|
14
|
+
* name: 'MyApp',
|
|
15
|
+
* version: '1.0.0',
|
|
16
|
+
* resources: [entrypointResource],
|
|
17
|
+
* metadata: {
|
|
18
|
+
* runtime: 'node',
|
|
19
|
+
* entrypoint: 'index.js',
|
|
20
|
+
* },
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* // Validate the manifest
|
|
24
|
+
* const registry = KindRegistry.getInstance();
|
|
25
|
+
* const result = registry.validate(appManifest);
|
|
26
|
+
* if (!result.isValid) {
|
|
27
|
+
* console.error('Validation errors:', result.errors);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
// Type exports
|
|
32
|
+
export { OriginalKind, } from './types';
|
|
33
|
+
// Registry export
|
|
34
|
+
export { KindRegistry } from './KindRegistry';
|
|
35
|
+
// Validator exports (for extension/customization)
|
|
36
|
+
export { BaseKindValidator, ValidationUtils, AppValidator, AgentValidator, ModuleValidator, DatasetValidator, MediaValidator, DocumentValidator, } from './validators';
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Originals Kind System Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the typed "Kinds" for Originals - a classification system that
|
|
5
|
+
* enables kind-specific validation, metadata schemas, and behaviors.
|
|
6
|
+
*/
|
|
7
|
+
import type { AssetResource } from '../types/common';
|
|
8
|
+
/**
|
|
9
|
+
* The supported Original kinds
|
|
10
|
+
* Each kind represents a category of digital asset with specific requirements
|
|
11
|
+
*/
|
|
12
|
+
export declare enum OriginalKind {
|
|
13
|
+
/** Executable application with runtime and entrypoint */
|
|
14
|
+
App = "originals:kind:app",
|
|
15
|
+
/** AI agent or autonomous system with capabilities and model info */
|
|
16
|
+
Agent = "originals:kind:agent",
|
|
17
|
+
/** Reusable code module with exports and dependencies */
|
|
18
|
+
Module = "originals:kind:module",
|
|
19
|
+
/** Structured data collection with schema definition */
|
|
20
|
+
Dataset = "originals:kind:dataset",
|
|
21
|
+
/** Media content (image, audio, video) with format metadata */
|
|
22
|
+
Media = "originals:kind:media",
|
|
23
|
+
/** Text document with formatting and sections */
|
|
24
|
+
Document = "originals:kind:document"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reference to a dependency Original
|
|
28
|
+
*/
|
|
29
|
+
export interface DependencyRef {
|
|
30
|
+
/** DID of the dependency Original */
|
|
31
|
+
did: string;
|
|
32
|
+
/** Semantic version constraint (e.g., "^1.0.0", ">=2.0.0") */
|
|
33
|
+
version?: string;
|
|
34
|
+
/** Human-readable name of the dependency */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Whether this dependency is required (default: true) */
|
|
37
|
+
optional?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Base manifest fields shared by all kinds
|
|
41
|
+
*/
|
|
42
|
+
export interface BaseManifest {
|
|
43
|
+
/** Human-readable name */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Semantic version string (e.g., "1.0.0") */
|
|
46
|
+
version: string;
|
|
47
|
+
/** Optional description */
|
|
48
|
+
description?: string;
|
|
49
|
+
/** Resources associated with this Original */
|
|
50
|
+
resources: AssetResource[];
|
|
51
|
+
/** Dependencies on other Originals */
|
|
52
|
+
dependencies?: DependencyRef[];
|
|
53
|
+
/** Free-form tags for categorization */
|
|
54
|
+
tags?: string[];
|
|
55
|
+
/** Author information */
|
|
56
|
+
author?: {
|
|
57
|
+
name?: string;
|
|
58
|
+
did?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
url?: string;
|
|
61
|
+
};
|
|
62
|
+
/** License identifier (SPDX) */
|
|
63
|
+
license?: string;
|
|
64
|
+
/** URL for more information */
|
|
65
|
+
homepage?: string;
|
|
66
|
+
/** Repository URL */
|
|
67
|
+
repository?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* App-specific metadata
|
|
71
|
+
*/
|
|
72
|
+
export interface AppMetadata {
|
|
73
|
+
/** Runtime environment (e.g., "node", "browser", "deno", "bun") */
|
|
74
|
+
runtime: string;
|
|
75
|
+
/** Entrypoint resource ID or path */
|
|
76
|
+
entrypoint: string;
|
|
77
|
+
/** Required runtime version */
|
|
78
|
+
runtimeVersion?: string;
|
|
79
|
+
/** Minimum required runtime version */
|
|
80
|
+
minRuntimeVersion?: string;
|
|
81
|
+
/** App permissions required */
|
|
82
|
+
permissions?: string[];
|
|
83
|
+
/** Environment variables expected */
|
|
84
|
+
env?: Record<string, {
|
|
85
|
+
description?: string;
|
|
86
|
+
required?: boolean;
|
|
87
|
+
default?: string;
|
|
88
|
+
}>;
|
|
89
|
+
/** Supported platforms */
|
|
90
|
+
platforms?: ('linux' | 'darwin' | 'windows' | 'web')[];
|
|
91
|
+
/** App icons by size */
|
|
92
|
+
icons?: Record<string, string>;
|
|
93
|
+
/** CLI commands exposed */
|
|
94
|
+
commands?: Record<string, {
|
|
95
|
+
description: string;
|
|
96
|
+
args?: string[];
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Agent-specific metadata
|
|
101
|
+
*/
|
|
102
|
+
export interface AgentMetadata {
|
|
103
|
+
/** Agent capabilities/skills */
|
|
104
|
+
capabilities: string[];
|
|
105
|
+
/** Model information if AI-based */
|
|
106
|
+
model?: {
|
|
107
|
+
provider?: string;
|
|
108
|
+
name: string;
|
|
109
|
+
version?: string;
|
|
110
|
+
parameters?: Record<string, unknown>;
|
|
111
|
+
};
|
|
112
|
+
/** Input types the agent accepts */
|
|
113
|
+
inputTypes?: string[];
|
|
114
|
+
/** Output types the agent produces */
|
|
115
|
+
outputTypes?: string[];
|
|
116
|
+
/** Memory/state configuration */
|
|
117
|
+
memory?: {
|
|
118
|
+
type: 'stateless' | 'session' | 'persistent';
|
|
119
|
+
maxSize?: number;
|
|
120
|
+
};
|
|
121
|
+
/** System prompt or instructions */
|
|
122
|
+
systemPrompt?: string;
|
|
123
|
+
/** Tools/functions the agent can use */
|
|
124
|
+
tools?: Array<{
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
parameters?: Record<string, unknown>;
|
|
128
|
+
}>;
|
|
129
|
+
/** Rate limiting configuration */
|
|
130
|
+
rateLimit?: {
|
|
131
|
+
requestsPerMinute?: number;
|
|
132
|
+
tokensPerMinute?: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Module-specific metadata
|
|
137
|
+
*/
|
|
138
|
+
export interface ModuleMetadata {
|
|
139
|
+
/** Module format (esm, commonjs, umd, etc.) */
|
|
140
|
+
format: 'esm' | 'commonjs' | 'umd' | 'amd' | 'iife';
|
|
141
|
+
/** Main entrypoint file (resource ID) */
|
|
142
|
+
main: string;
|
|
143
|
+
/** Types definition file (resource ID) */
|
|
144
|
+
types?: string;
|
|
145
|
+
/** Exported symbols/functions */
|
|
146
|
+
exports?: Record<string, string | {
|
|
147
|
+
import?: string;
|
|
148
|
+
require?: string;
|
|
149
|
+
types?: string;
|
|
150
|
+
}>;
|
|
151
|
+
/** Peer dependencies (expected to be provided by consumer) */
|
|
152
|
+
peerDependencies?: Record<string, string>;
|
|
153
|
+
/** Browser-specific entrypoint */
|
|
154
|
+
browser?: string;
|
|
155
|
+
/** Files included in the module */
|
|
156
|
+
files?: string[];
|
|
157
|
+
/** Side effects declaration */
|
|
158
|
+
sideEffects?: boolean | string[];
|
|
159
|
+
/** TypeScript configuration */
|
|
160
|
+
typescript?: {
|
|
161
|
+
strict?: boolean;
|
|
162
|
+
target?: string;
|
|
163
|
+
moduleResolution?: string;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Dataset-specific metadata
|
|
168
|
+
*/
|
|
169
|
+
export interface DatasetMetadata {
|
|
170
|
+
/** Schema definition (JSON Schema, or URL to schema) */
|
|
171
|
+
schema: Record<string, unknown> | string;
|
|
172
|
+
/** Data format (csv, json, parquet, etc.) */
|
|
173
|
+
format: string;
|
|
174
|
+
/** Number of records/rows */
|
|
175
|
+
recordCount?: number;
|
|
176
|
+
/** Data columns/fields */
|
|
177
|
+
columns?: Array<{
|
|
178
|
+
name: string;
|
|
179
|
+
type: string;
|
|
180
|
+
description?: string;
|
|
181
|
+
nullable?: boolean;
|
|
182
|
+
}>;
|
|
183
|
+
/** Data source information */
|
|
184
|
+
source?: {
|
|
185
|
+
origin?: string;
|
|
186
|
+
collectedAt?: string;
|
|
187
|
+
methodology?: string;
|
|
188
|
+
};
|
|
189
|
+
/** Dataset statistics */
|
|
190
|
+
statistics?: {
|
|
191
|
+
sizeBytes?: number;
|
|
192
|
+
compression?: string;
|
|
193
|
+
checksums?: Record<string, string>;
|
|
194
|
+
};
|
|
195
|
+
/** License specific to the data */
|
|
196
|
+
dataLicense?: string;
|
|
197
|
+
/** Privacy classification */
|
|
198
|
+
privacy?: 'public' | 'internal' | 'confidential' | 'restricted';
|
|
199
|
+
/** Update frequency */
|
|
200
|
+
updateFrequency?: 'realtime' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'static';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Media-specific metadata
|
|
204
|
+
*/
|
|
205
|
+
export interface MediaMetadata {
|
|
206
|
+
/** Media type (image, audio, video, 3d) */
|
|
207
|
+
mediaType: 'image' | 'audio' | 'video' | '3d' | 'animation';
|
|
208
|
+
/** MIME type of the primary media resource */
|
|
209
|
+
mimeType: string;
|
|
210
|
+
/** Dimensions (for images and video) */
|
|
211
|
+
dimensions?: {
|
|
212
|
+
width: number;
|
|
213
|
+
height: number;
|
|
214
|
+
aspectRatio?: string;
|
|
215
|
+
};
|
|
216
|
+
/** Duration in seconds (for audio/video) */
|
|
217
|
+
duration?: number;
|
|
218
|
+
/** Frame rate (for video/animation) */
|
|
219
|
+
frameRate?: number;
|
|
220
|
+
/** Audio channels (for audio/video) */
|
|
221
|
+
audioChannels?: number;
|
|
222
|
+
/** Sample rate (for audio) */
|
|
223
|
+
sampleRate?: number;
|
|
224
|
+
/** Codec information */
|
|
225
|
+
codec?: string;
|
|
226
|
+
/** Bitrate in kbps */
|
|
227
|
+
bitrate?: number;
|
|
228
|
+
/** Color space */
|
|
229
|
+
colorSpace?: string;
|
|
230
|
+
/** Thumbnail resource ID */
|
|
231
|
+
thumbnail?: string;
|
|
232
|
+
/** Preview/low-res version resource ID */
|
|
233
|
+
preview?: string;
|
|
234
|
+
/** Alt text for accessibility */
|
|
235
|
+
altText?: string;
|
|
236
|
+
/** Caption or transcript */
|
|
237
|
+
caption?: string;
|
|
238
|
+
/** EXIF or similar metadata */
|
|
239
|
+
exif?: Record<string, unknown>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Document-specific metadata
|
|
243
|
+
*/
|
|
244
|
+
export interface DocumentMetadata {
|
|
245
|
+
/** Document format (markdown, html, pdf, docx, etc.) */
|
|
246
|
+
format: 'markdown' | 'html' | 'pdf' | 'docx' | 'txt' | 'asciidoc' | 'rst' | 'latex';
|
|
247
|
+
/** Document language (ISO 639-1) */
|
|
248
|
+
language?: string;
|
|
249
|
+
/** Main content resource ID */
|
|
250
|
+
content: string;
|
|
251
|
+
/** Table of contents */
|
|
252
|
+
toc?: Array<{
|
|
253
|
+
title: string;
|
|
254
|
+
level: number;
|
|
255
|
+
anchor?: string;
|
|
256
|
+
}>;
|
|
257
|
+
/** Page count */
|
|
258
|
+
pageCount?: number;
|
|
259
|
+
/** Word count */
|
|
260
|
+
wordCount?: number;
|
|
261
|
+
/** Reading time in minutes */
|
|
262
|
+
readingTime?: number;
|
|
263
|
+
/** Keywords */
|
|
264
|
+
keywords?: string[];
|
|
265
|
+
/** Abstract or summary */
|
|
266
|
+
abstract?: string;
|
|
267
|
+
/** Bibliography/references */
|
|
268
|
+
references?: Array<{
|
|
269
|
+
id: string;
|
|
270
|
+
title: string;
|
|
271
|
+
authors?: string[];
|
|
272
|
+
year?: number;
|
|
273
|
+
url?: string;
|
|
274
|
+
doi?: string;
|
|
275
|
+
}>;
|
|
276
|
+
/** Document status */
|
|
277
|
+
status?: 'draft' | 'review' | 'published' | 'archived';
|
|
278
|
+
/** Revision number */
|
|
279
|
+
revision?: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Maps each kind to its specific metadata type
|
|
283
|
+
*/
|
|
284
|
+
export interface KindMetadataMap {
|
|
285
|
+
[OriginalKind.App]: AppMetadata;
|
|
286
|
+
[OriginalKind.Agent]: AgentMetadata;
|
|
287
|
+
[OriginalKind.Module]: ModuleMetadata;
|
|
288
|
+
[OriginalKind.Dataset]: DatasetMetadata;
|
|
289
|
+
[OriginalKind.Media]: MediaMetadata;
|
|
290
|
+
[OriginalKind.Document]: DocumentMetadata;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Type-safe metadata accessor
|
|
294
|
+
*/
|
|
295
|
+
export type KindMetadata<K extends OriginalKind> = K extends keyof KindMetadataMap ? KindMetadataMap[K] : never;
|
|
296
|
+
/**
|
|
297
|
+
* Generic Original manifest with kind-specific metadata
|
|
298
|
+
*/
|
|
299
|
+
export interface OriginalManifest<K extends OriginalKind = OriginalKind> extends BaseManifest {
|
|
300
|
+
/** The kind of Original */
|
|
301
|
+
kind: K;
|
|
302
|
+
/** Kind-specific metadata */
|
|
303
|
+
metadata: KindMetadata<K>;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Type-specific manifest aliases for convenience
|
|
307
|
+
*/
|
|
308
|
+
export type AppManifest = OriginalManifest<OriginalKind.App>;
|
|
309
|
+
export type AgentManifest = OriginalManifest<OriginalKind.Agent>;
|
|
310
|
+
export type ModuleManifest = OriginalManifest<OriginalKind.Module>;
|
|
311
|
+
export type DatasetManifest = OriginalManifest<OriginalKind.Dataset>;
|
|
312
|
+
export type MediaManifest = OriginalManifest<OriginalKind.Media>;
|
|
313
|
+
export type DocumentManifest = OriginalManifest<OriginalKind.Document>;
|
|
314
|
+
/**
|
|
315
|
+
* Union type of all possible manifests
|
|
316
|
+
*/
|
|
317
|
+
export type AnyManifest = AppManifest | AgentManifest | ModuleManifest | DatasetManifest | MediaManifest | DocumentManifest;
|
|
318
|
+
/**
|
|
319
|
+
* Result of validating a manifest
|
|
320
|
+
*/
|
|
321
|
+
export interface ValidationResult {
|
|
322
|
+
/** Whether the manifest is valid */
|
|
323
|
+
isValid: boolean;
|
|
324
|
+
/** Validation errors if any */
|
|
325
|
+
errors: ValidationError[];
|
|
326
|
+
/** Validation warnings (non-fatal) */
|
|
327
|
+
warnings: ValidationWarning[];
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* A validation error
|
|
331
|
+
*/
|
|
332
|
+
export interface ValidationError {
|
|
333
|
+
/** Error code */
|
|
334
|
+
code: string;
|
|
335
|
+
/** Human-readable message */
|
|
336
|
+
message: string;
|
|
337
|
+
/** Path to the invalid field (e.g., "metadata.entrypoint") */
|
|
338
|
+
path?: string;
|
|
339
|
+
/** The invalid value */
|
|
340
|
+
value?: unknown;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* A validation warning (non-fatal issue)
|
|
344
|
+
*/
|
|
345
|
+
export interface ValidationWarning {
|
|
346
|
+
/** Warning code */
|
|
347
|
+
code: string;
|
|
348
|
+
/** Human-readable message */
|
|
349
|
+
message: string;
|
|
350
|
+
/** Path to the field with warning */
|
|
351
|
+
path?: string;
|
|
352
|
+
/** Suggested fix */
|
|
353
|
+
suggestion?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Options for creating a typed Original
|
|
357
|
+
*/
|
|
358
|
+
export interface CreateTypedOriginalOptions {
|
|
359
|
+
/** Skip validation (not recommended) */
|
|
360
|
+
skipValidation?: boolean;
|
|
361
|
+
/** Treat warnings as errors */
|
|
362
|
+
strictMode?: boolean;
|
|
363
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Originals Kind System Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the typed "Kinds" for Originals - a classification system that
|
|
5
|
+
* enables kind-specific validation, metadata schemas, and behaviors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The supported Original kinds
|
|
9
|
+
* Each kind represents a category of digital asset with specific requirements
|
|
10
|
+
*/
|
|
11
|
+
export var OriginalKind;
|
|
12
|
+
(function (OriginalKind) {
|
|
13
|
+
/** Executable application with runtime and entrypoint */
|
|
14
|
+
OriginalKind["App"] = "originals:kind:app";
|
|
15
|
+
/** AI agent or autonomous system with capabilities and model info */
|
|
16
|
+
OriginalKind["Agent"] = "originals:kind:agent";
|
|
17
|
+
/** Reusable code module with exports and dependencies */
|
|
18
|
+
OriginalKind["Module"] = "originals:kind:module";
|
|
19
|
+
/** Structured data collection with schema definition */
|
|
20
|
+
OriginalKind["Dataset"] = "originals:kind:dataset";
|
|
21
|
+
/** Media content (image, audio, video) with format metadata */
|
|
22
|
+
OriginalKind["Media"] = "originals:kind:media";
|
|
23
|
+
/** Text document with formatting and sections */
|
|
24
|
+
OriginalKind["Document"] = "originals:kind:document";
|
|
25
|
+
})(OriginalKind || (OriginalKind = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Kind Validator
|
|
3
|
+
*
|
|
4
|
+
* Validates manifests for AI agents or autonomous systems with capabilities and model info.
|
|
5
|
+
*/
|
|
6
|
+
import { OriginalKind, type OriginalManifest, type ValidationResult } from '../types';
|
|
7
|
+
import { BaseKindValidator } from './base';
|
|
8
|
+
/**
|
|
9
|
+
* Validator for Agent Originals
|
|
10
|
+
*/
|
|
11
|
+
export declare class AgentValidator extends BaseKindValidator<OriginalKind.Agent> {
|
|
12
|
+
readonly kind = OriginalKind.Agent;
|
|
13
|
+
protected validateKind(manifest: OriginalManifest<OriginalKind.Agent>): ValidationResult;
|
|
14
|
+
}
|