@originals/sdk 1.1.0 → 1.4.2
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/package.json +3 -2
- package/src/did/DIDManager.ts +1 -1
- package/src/did/WebVHManager.ts +11 -2
- package/src/examples/create-module-original.ts +435 -0
- package/src/examples/full-lifecycle-flow.ts +514 -0
- package/src/examples/run.ts +59 -4
- package/src/index.ts +69 -3
- package/src/kinds/KindRegistry.ts +290 -0
- package/src/kinds/index.ts +74 -0
- package/src/kinds/types.ts +470 -0
- package/src/kinds/validators/AgentValidator.ts +257 -0
- package/src/kinds/validators/AppValidator.ts +211 -0
- package/src/kinds/validators/DatasetValidator.ts +242 -0
- package/src/kinds/validators/DocumentValidator.ts +311 -0
- package/src/kinds/validators/MediaValidator.ts +269 -0
- package/src/kinds/validators/ModuleValidator.ts +225 -0
- package/src/kinds/validators/base.ts +276 -0
- package/src/kinds/validators/index.ts +12 -0
- package/src/lifecycle/LifecycleManager.ts +909 -1
- package/src/resources/ResourceManager.ts +655 -0
- package/src/resources/index.ts +21 -0
- package/src/resources/types.ts +202 -0
- package/src/types/common.ts +1 -1
- package/src/vc/CredentialManager.ts +647 -2
- package/tests/integration/createTypedOriginal.test.ts +379 -0
- package/tests/performance/BatchOperations.perf.test.ts +2 -2
- package/tests/unit/kinds/KindRegistry.test.ts +329 -0
- package/tests/unit/kinds/types.test.ts +409 -0
- package/tests/unit/kinds/validators.test.ts +651 -0
- package/tests/unit/lifecycle/LifecycleManager.cleanapi.test.ts +441 -0
- package/tests/unit/resources/ResourceManager.test.ts +740 -0
- package/tests/unit/vc/CredentialManager.helpers.test.ts +527 -0
- package/tsconfig.json +0 -1
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-test.log +0 -68353
- package/dist/adapters/FeeOracleMock.d.ts +0 -6
- package/dist/adapters/FeeOracleMock.js +0 -8
- package/dist/adapters/index.d.ts +0 -4
- package/dist/adapters/index.js +0 -4
- package/dist/adapters/providers/OrdHttpProvider.d.ts +0 -56
- package/dist/adapters/providers/OrdHttpProvider.js +0 -110
- package/dist/adapters/providers/OrdMockProvider.d.ts +0 -70
- package/dist/adapters/providers/OrdMockProvider.js +0 -75
- package/dist/adapters/types.d.ts +0 -71
- package/dist/adapters/types.js +0 -1
- package/dist/bitcoin/BitcoinManager.d.ts +0 -15
- package/dist/bitcoin/BitcoinManager.js +0 -262
- package/dist/bitcoin/BroadcastClient.d.ts +0 -30
- package/dist/bitcoin/BroadcastClient.js +0 -35
- package/dist/bitcoin/OrdinalsClient.d.ts +0 -21
- package/dist/bitcoin/OrdinalsClient.js +0 -105
- package/dist/bitcoin/PSBTBuilder.d.ts +0 -24
- package/dist/bitcoin/PSBTBuilder.js +0 -80
- package/dist/bitcoin/fee-calculation.d.ts +0 -14
- package/dist/bitcoin/fee-calculation.js +0 -31
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +0 -38
- package/dist/bitcoin/providers/OrdNodeProvider.js +0 -67
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +0 -33
- package/dist/bitcoin/providers/OrdinalsProvider.js +0 -50
- package/dist/bitcoin/providers/types.d.ts +0 -63
- package/dist/bitcoin/providers/types.js +0 -1
- package/dist/bitcoin/transactions/commit.d.ts +0 -89
- package/dist/bitcoin/transactions/commit.js +0 -311
- package/dist/bitcoin/transactions/index.d.ts +0 -7
- package/dist/bitcoin/transactions/index.js +0 -8
- package/dist/bitcoin/transfer.d.ts +0 -9
- package/dist/bitcoin/transfer.js +0 -26
- package/dist/bitcoin/utxo-selection.d.ts +0 -78
- package/dist/bitcoin/utxo-selection.js +0 -237
- package/dist/bitcoin/utxo.d.ts +0 -26
- package/dist/bitcoin/utxo.js +0 -78
- package/dist/contexts/credentials-v1.json +0 -195
- package/dist/contexts/credentials-v2-examples.json +0 -5
- package/dist/contexts/credentials-v2.json +0 -301
- package/dist/contexts/credentials.json +0 -195
- package/dist/contexts/data-integrity-v2.json +0 -81
- package/dist/contexts/dids.json +0 -57
- package/dist/contexts/ed255192020.json +0 -93
- package/dist/contexts/ordinals-plus.json +0 -23
- package/dist/contexts/originals.json +0 -22
- package/dist/core/OriginalsSDK.d.ts +0 -158
- package/dist/core/OriginalsSDK.js +0 -274
- package/dist/crypto/Multikey.d.ts +0 -30
- package/dist/crypto/Multikey.js +0 -149
- package/dist/crypto/Signer.d.ts +0 -21
- package/dist/crypto/Signer.js +0 -196
- package/dist/crypto/noble-init.d.ts +0 -18
- package/dist/crypto/noble-init.js +0 -106
- package/dist/did/BtcoDidResolver.d.ts +0 -57
- package/dist/did/BtcoDidResolver.js +0 -166
- package/dist/did/DIDManager.d.ts +0 -101
- package/dist/did/DIDManager.js +0 -493
- package/dist/did/Ed25519Verifier.d.ts +0 -30
- package/dist/did/Ed25519Verifier.js +0 -59
- package/dist/did/KeyManager.d.ts +0 -17
- package/dist/did/KeyManager.js +0 -207
- package/dist/did/WebVHManager.d.ts +0 -100
- package/dist/did/WebVHManager.js +0 -304
- package/dist/did/createBtcoDidDocument.d.ts +0 -10
- package/dist/did/createBtcoDidDocument.js +0 -42
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +0 -23
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +0 -51
- package/dist/events/EventEmitter.d.ts +0 -115
- package/dist/events/EventEmitter.js +0 -198
- package/dist/events/index.d.ts +0 -7
- package/dist/events/index.js +0 -6
- package/dist/events/types.d.ts +0 -286
- package/dist/events/types.js +0 -9
- package/dist/examples/basic-usage.d.ts +0 -3
- package/dist/examples/basic-usage.js +0 -62
- package/dist/examples/run.d.ts +0 -1
- package/dist/examples/run.js +0 -4
- package/dist/index.d.ts +0 -39
- package/dist/index.js +0 -47
- package/dist/lifecycle/BatchOperations.d.ts +0 -147
- package/dist/lifecycle/BatchOperations.js +0 -251
- package/dist/lifecycle/LifecycleManager.d.ts +0 -116
- package/dist/lifecycle/LifecycleManager.js +0 -971
- package/dist/lifecycle/OriginalsAsset.d.ts +0 -164
- package/dist/lifecycle/OriginalsAsset.js +0 -380
- package/dist/lifecycle/ProvenanceQuery.d.ts +0 -126
- package/dist/lifecycle/ProvenanceQuery.js +0 -220
- package/dist/lifecycle/ResourceVersioning.d.ts +0 -73
- package/dist/lifecycle/ResourceVersioning.js +0 -127
- package/dist/migration/MigrationManager.d.ts +0 -86
- package/dist/migration/MigrationManager.js +0 -412
- package/dist/migration/audit/AuditLogger.d.ts +0 -51
- package/dist/migration/audit/AuditLogger.js +0 -156
- package/dist/migration/checkpoint/CheckpointManager.d.ts +0 -31
- package/dist/migration/checkpoint/CheckpointManager.js +0 -96
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +0 -26
- package/dist/migration/checkpoint/CheckpointStorage.js +0 -89
- package/dist/migration/index.d.ts +0 -22
- package/dist/migration/index.js +0 -27
- package/dist/migration/operations/BaseMigration.d.ts +0 -48
- package/dist/migration/operations/BaseMigration.js +0 -83
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/PeerToBtcoMigration.js +0 -67
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +0 -19
- package/dist/migration/operations/PeerToWebvhMigration.js +0 -46
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/WebvhToBtcoMigration.js +0 -67
- package/dist/migration/rollback/RollbackManager.d.ts +0 -29
- package/dist/migration/rollback/RollbackManager.js +0 -146
- package/dist/migration/state/StateMachine.d.ts +0 -25
- package/dist/migration/state/StateMachine.js +0 -76
- package/dist/migration/state/StateTracker.d.ts +0 -36
- package/dist/migration/state/StateTracker.js +0 -123
- package/dist/migration/types.d.ts +0 -306
- package/dist/migration/types.js +0 -33
- package/dist/migration/validation/BitcoinValidator.d.ts +0 -13
- package/dist/migration/validation/BitcoinValidator.js +0 -83
- package/dist/migration/validation/CredentialValidator.d.ts +0 -13
- package/dist/migration/validation/CredentialValidator.js +0 -46
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +0 -16
- package/dist/migration/validation/DIDCompatibilityValidator.js +0 -127
- package/dist/migration/validation/LifecycleValidator.d.ts +0 -10
- package/dist/migration/validation/LifecycleValidator.js +0 -52
- package/dist/migration/validation/StorageValidator.d.ts +0 -10
- package/dist/migration/validation/StorageValidator.js +0 -65
- package/dist/migration/validation/ValidationPipeline.d.ts +0 -29
- package/dist/migration/validation/ValidationPipeline.js +0 -180
- package/dist/storage/LocalStorageAdapter.d.ts +0 -11
- package/dist/storage/LocalStorageAdapter.js +0 -53
- package/dist/storage/MemoryStorageAdapter.d.ts +0 -6
- package/dist/storage/MemoryStorageAdapter.js +0 -21
- package/dist/storage/StorageAdapter.d.ts +0 -16
- package/dist/storage/StorageAdapter.js +0 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -2
- package/dist/types/bitcoin.d.ts +0 -84
- package/dist/types/bitcoin.js +0 -1
- package/dist/types/common.d.ts +0 -82
- package/dist/types/common.js +0 -1
- package/dist/types/credentials.d.ts +0 -75
- package/dist/types/credentials.js +0 -1
- package/dist/types/did.d.ts +0 -26
- package/dist/types/did.js +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types/network.d.ts +0 -78
- package/dist/types/network.js +0 -145
- package/dist/utils/EventLogger.d.ts +0 -71
- package/dist/utils/EventLogger.js +0 -232
- package/dist/utils/Logger.d.ts +0 -106
- package/dist/utils/Logger.js +0 -257
- package/dist/utils/MetricsCollector.d.ts +0 -110
- package/dist/utils/MetricsCollector.js +0 -264
- package/dist/utils/bitcoin-address.d.ts +0 -38
- package/dist/utils/bitcoin-address.js +0 -113
- package/dist/utils/cbor.d.ts +0 -2
- package/dist/utils/cbor.js +0 -9
- package/dist/utils/encoding.d.ts +0 -37
- package/dist/utils/encoding.js +0 -120
- package/dist/utils/hash.d.ts +0 -1
- package/dist/utils/hash.js +0 -5
- package/dist/utils/retry.d.ts +0 -10
- package/dist/utils/retry.js +0 -35
- package/dist/utils/satoshi-validation.d.ts +0 -60
- package/dist/utils/satoshi-validation.js +0 -156
- package/dist/utils/serialization.d.ts +0 -14
- package/dist/utils/serialization.js +0 -76
- package/dist/utils/telemetry.d.ts +0 -17
- package/dist/utils/telemetry.js +0 -24
- package/dist/utils/validation.d.ts +0 -5
- package/dist/utils/validation.js +0 -98
- package/dist/vc/CredentialManager.d.ts +0 -22
- package/dist/vc/CredentialManager.js +0 -227
- package/dist/vc/Issuer.d.ts +0 -27
- package/dist/vc/Issuer.js +0 -70
- package/dist/vc/Verifier.d.ts +0 -16
- package/dist/vc/Verifier.js +0 -50
- package/dist/vc/cryptosuites/bbs.d.ts +0 -44
- package/dist/vc/cryptosuites/bbs.js +0 -213
- package/dist/vc/cryptosuites/bbsSimple.d.ts +0 -9
- package/dist/vc/cryptosuites/bbsSimple.js +0 -12
- package/dist/vc/cryptosuites/eddsa.d.ts +0 -30
- package/dist/vc/cryptosuites/eddsa.js +0 -81
- package/dist/vc/documentLoader.d.ts +0 -16
- package/dist/vc/documentLoader.js +0 -59
- package/dist/vc/proofs/data-integrity.d.ts +0 -21
- package/dist/vc/proofs/data-integrity.js +0 -15
- package/dist/vc/utils/jsonld.d.ts +0 -2
- package/dist/vc/utils/jsonld.js +0 -15
- package/test/logs/did_webvh_QmQsRNhXxPSCSeLjpbKYcNMZj8b1kBQAoC6cZmkFAgmpHt_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmSQkpD58qxcqMWHYcEmDUn3wk7hHvJwzYTrZmhh6zjPQ8_example_com_users_alice123_profile.jsonl +0 -1
- package/test/logs/did_webvh_QmTMda6VW3cUPdKk5Yc3onnv1vdgEumvWWdP2noAYFSjeG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmTkb8KnCYcsnKKDCY4eUQuKQdKJLrCinvhw13v3zETxpE_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmTn9FdCfpXFDrxHH52pwB4iNrDFVvNDjJ5FQTcDbmM3Fg_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUCQUi1xjtJjnSQ1XJZgKqcWgErx1v7E2dz4DAPraAyJP_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmUENQJCDKBJVRS5BkL6zjaUvcRjkb9xHmy7foCgRjmv3W_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUPdGyjYBEnQ3aQUkmqyyBKTyjvCP5RZQGiaEDeTtf6dc_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUoHTuHMWzQM29ZFrE9VLtMxkZ5u869yqee8LwcCLN39M_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUrnms8G65ggVKsr9oQeWrLUBuGChwQPPb2LCFvaoNxaw_example_com_users_alice.jsonl +0 -1
- package/test/logs/did_webvh_QmUwiw3eSXdHG1hPvoAGu3cuK5jF4aXRYDLBAjPXfv1qzb_example_com_level1_level2.jsonl +0 -1
- package/test/logs/did_webvh_QmW7bzKh6yFEKNAtmVsrPGvvsMHTUQdzJSNsTZkbuGFpbj_example_com_secret.jsonl +0 -1
- package/test/logs/did_webvh_QmXbFTFBBJ8zpjdz9WE1DNN44A2wprFmdvAubjSffeyoAG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmXyVXFPCTffGb2mTUFDeMCsScjnpLWkyUkVkB6q6QoeBf_example_com_C_Windows_System32.jsonl +0 -1
- package/test/logs/did_webvh_QmZK9B81gxZtvo5fYHYKDtKt8zZfZZPhmCMhbujBJuRRzE_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmbNLCVSdXSVLrwFBvCBQPAabjtRb1SGHjkGVyw3QUbfBL_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmbeaicmGW3Q7Yzbqmftc8a9jLBngokveb5A2KVKfVGZRb_example_com_my_org_user_name_test_123.jsonl +0 -1
- package/test/logs/did_webvh_Qmdv7c7AjUreUfoKyvkN2UpAWTozxKsv99srQetPJMJEnp_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmeioWY3uypYLkYpCXe9eCYnn4xBVruP9C1d79azMrTEHG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_Qmf4QH5dsA6Ecr5HJ6KaJL9uJRyY8RxrQdqoRCM25DzvPi_example_com_users_alice.jsonl +0 -1
- package/tests/e2e/README.md +0 -97
- package/tests/e2e/example.spec.ts +0 -78
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Kind types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from 'bun:test';
|
|
6
|
+
import {
|
|
7
|
+
OriginalKind,
|
|
8
|
+
type OriginalManifest,
|
|
9
|
+
type AppManifest,
|
|
10
|
+
type ModuleManifest,
|
|
11
|
+
type DatasetManifest,
|
|
12
|
+
type AgentManifest,
|
|
13
|
+
type MediaManifest,
|
|
14
|
+
type DocumentManifest,
|
|
15
|
+
} from '../../../src/kinds';
|
|
16
|
+
|
|
17
|
+
describe('OriginalKind enum', () => {
|
|
18
|
+
it('should have all expected kinds', () => {
|
|
19
|
+
expect(OriginalKind.App).toBe('originals:kind:app');
|
|
20
|
+
expect(OriginalKind.Agent).toBe('originals:kind:agent');
|
|
21
|
+
expect(OriginalKind.Module).toBe('originals:kind:module');
|
|
22
|
+
expect(OriginalKind.Dataset).toBe('originals:kind:dataset');
|
|
23
|
+
expect(OriginalKind.Media).toBe('originals:kind:media');
|
|
24
|
+
expect(OriginalKind.Document).toBe('originals:kind:document');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should have exactly 6 kinds', () => {
|
|
28
|
+
const kindCount = Object.values(OriginalKind).length;
|
|
29
|
+
expect(kindCount).toBe(6);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should follow originals:kind: prefix pattern', () => {
|
|
33
|
+
for (const kind of Object.values(OriginalKind)) {
|
|
34
|
+
expect(kind.startsWith('originals:kind:')).toBe(true);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('AppManifest type', () => {
|
|
40
|
+
it('should allow valid app manifest', () => {
|
|
41
|
+
const manifest: AppManifest = {
|
|
42
|
+
kind: OriginalKind.App,
|
|
43
|
+
name: 'MyApp',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
resources: [{
|
|
46
|
+
id: 'index.js',
|
|
47
|
+
type: 'code',
|
|
48
|
+
contentType: 'application/javascript',
|
|
49
|
+
hash: 'abc123',
|
|
50
|
+
}],
|
|
51
|
+
metadata: {
|
|
52
|
+
runtime: 'node',
|
|
53
|
+
entrypoint: 'index.js',
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
expect(manifest.kind).toBe(OriginalKind.App);
|
|
58
|
+
expect(manifest.metadata.runtime).toBe('node');
|
|
59
|
+
expect(manifest.metadata.entrypoint).toBe('index.js');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should allow all optional metadata fields', () => {
|
|
63
|
+
const manifest: AppManifest = {
|
|
64
|
+
kind: OriginalKind.App,
|
|
65
|
+
name: 'FullApp',
|
|
66
|
+
version: '2.0.0',
|
|
67
|
+
description: 'A full-featured app',
|
|
68
|
+
resources: [{
|
|
69
|
+
id: 'main.js',
|
|
70
|
+
type: 'code',
|
|
71
|
+
contentType: 'application/javascript',
|
|
72
|
+
hash: 'def456',
|
|
73
|
+
}],
|
|
74
|
+
dependencies: [{
|
|
75
|
+
did: 'did:peer:123',
|
|
76
|
+
version: '^1.0.0',
|
|
77
|
+
name: 'dep-lib',
|
|
78
|
+
}],
|
|
79
|
+
tags: ['utility', 'cli'],
|
|
80
|
+
author: {
|
|
81
|
+
name: 'Test Author',
|
|
82
|
+
did: 'did:peer:author',
|
|
83
|
+
},
|
|
84
|
+
license: 'MIT',
|
|
85
|
+
metadata: {
|
|
86
|
+
runtime: 'bun',
|
|
87
|
+
entrypoint: 'main.js',
|
|
88
|
+
runtimeVersion: '1.0.0',
|
|
89
|
+
permissions: ['network', 'filesystem'],
|
|
90
|
+
platforms: ['linux', 'darwin'],
|
|
91
|
+
env: {
|
|
92
|
+
PORT: { description: 'Server port', default: '3000' },
|
|
93
|
+
},
|
|
94
|
+
commands: {
|
|
95
|
+
start: { description: 'Start the server' },
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
expect(manifest.metadata.platforms).toContain('linux');
|
|
101
|
+
expect(manifest.metadata.permissions).toContain('network');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('ModuleManifest type', () => {
|
|
106
|
+
it('should allow valid module manifest', () => {
|
|
107
|
+
const manifest: ModuleManifest = {
|
|
108
|
+
kind: OriginalKind.Module,
|
|
109
|
+
name: 'my-module',
|
|
110
|
+
version: '1.0.0',
|
|
111
|
+
resources: [{
|
|
112
|
+
id: 'index.js',
|
|
113
|
+
type: 'code',
|
|
114
|
+
contentType: 'application/javascript',
|
|
115
|
+
hash: 'abc123',
|
|
116
|
+
}],
|
|
117
|
+
metadata: {
|
|
118
|
+
format: 'esm',
|
|
119
|
+
main: 'index.js',
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
expect(manifest.metadata.format).toBe('esm');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should allow conditional exports', () => {
|
|
127
|
+
const manifest: ModuleManifest = {
|
|
128
|
+
kind: OriginalKind.Module,
|
|
129
|
+
name: 'dual-module',
|
|
130
|
+
version: '1.0.0',
|
|
131
|
+
resources: [{
|
|
132
|
+
id: 'index.mjs',
|
|
133
|
+
type: 'code',
|
|
134
|
+
contentType: 'application/javascript',
|
|
135
|
+
hash: 'abc',
|
|
136
|
+
}],
|
|
137
|
+
metadata: {
|
|
138
|
+
format: 'esm',
|
|
139
|
+
main: 'index.mjs',
|
|
140
|
+
exports: {
|
|
141
|
+
'.': {
|
|
142
|
+
import: './index.mjs',
|
|
143
|
+
require: './index.cjs',
|
|
144
|
+
types: './index.d.ts',
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
expect(manifest.metadata.exports?.['.']).toBeDefined();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('DatasetManifest type', () => {
|
|
155
|
+
it('should allow valid dataset manifest', () => {
|
|
156
|
+
const manifest: DatasetManifest = {
|
|
157
|
+
kind: OriginalKind.Dataset,
|
|
158
|
+
name: 'training-data',
|
|
159
|
+
version: '1.0.0',
|
|
160
|
+
resources: [{
|
|
161
|
+
id: 'data.csv',
|
|
162
|
+
type: 'data',
|
|
163
|
+
contentType: 'text/csv',
|
|
164
|
+
hash: 'data123',
|
|
165
|
+
}],
|
|
166
|
+
metadata: {
|
|
167
|
+
format: 'csv',
|
|
168
|
+
schema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
id: { type: 'string' },
|
|
172
|
+
value: { type: 'number' },
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
expect(manifest.metadata.format).toBe('csv');
|
|
179
|
+
expect(typeof manifest.metadata.schema).toBe('object');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('should allow columns definition', () => {
|
|
183
|
+
const manifest: DatasetManifest = {
|
|
184
|
+
kind: OriginalKind.Dataset,
|
|
185
|
+
name: 'columnar-data',
|
|
186
|
+
version: '1.0.0',
|
|
187
|
+
resources: [{
|
|
188
|
+
id: 'data.parquet',
|
|
189
|
+
type: 'data',
|
|
190
|
+
contentType: 'application/octet-stream',
|
|
191
|
+
hash: 'parq123',
|
|
192
|
+
}],
|
|
193
|
+
metadata: {
|
|
194
|
+
format: 'parquet',
|
|
195
|
+
schema: {},
|
|
196
|
+
recordCount: 1000000,
|
|
197
|
+
columns: [
|
|
198
|
+
{ name: 'id', type: 'string', description: 'Unique identifier' },
|
|
199
|
+
{ name: 'value', type: 'float64', nullable: true },
|
|
200
|
+
],
|
|
201
|
+
privacy: 'public',
|
|
202
|
+
updateFrequency: 'daily',
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
expect(manifest.metadata.columns?.length).toBe(2);
|
|
207
|
+
expect(manifest.metadata.privacy).toBe('public');
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe('AgentManifest type', () => {
|
|
212
|
+
it('should allow valid agent manifest', () => {
|
|
213
|
+
const manifest: AgentManifest = {
|
|
214
|
+
kind: OriginalKind.Agent,
|
|
215
|
+
name: 'my-agent',
|
|
216
|
+
version: '1.0.0',
|
|
217
|
+
resources: [{
|
|
218
|
+
id: 'agent.json',
|
|
219
|
+
type: 'config',
|
|
220
|
+
contentType: 'application/json',
|
|
221
|
+
hash: 'agent123',
|
|
222
|
+
}],
|
|
223
|
+
metadata: {
|
|
224
|
+
capabilities: ['text-generation', 'code-completion'],
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
expect(manifest.metadata.capabilities).toContain('text-generation');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should allow full model configuration', () => {
|
|
232
|
+
const manifest: AgentManifest = {
|
|
233
|
+
kind: OriginalKind.Agent,
|
|
234
|
+
name: 'ai-assistant',
|
|
235
|
+
version: '1.0.0',
|
|
236
|
+
resources: [{
|
|
237
|
+
id: 'config.json',
|
|
238
|
+
type: 'config',
|
|
239
|
+
contentType: 'application/json',
|
|
240
|
+
hash: 'cfg123',
|
|
241
|
+
}],
|
|
242
|
+
metadata: {
|
|
243
|
+
capabilities: ['chat', 'summarization'],
|
|
244
|
+
model: {
|
|
245
|
+
provider: 'anthropic',
|
|
246
|
+
name: 'claude-3',
|
|
247
|
+
version: 'sonnet',
|
|
248
|
+
parameters: { temperature: 0.7 },
|
|
249
|
+
},
|
|
250
|
+
inputTypes: ['text', 'image'],
|
|
251
|
+
outputTypes: ['text'],
|
|
252
|
+
memory: {
|
|
253
|
+
type: 'session',
|
|
254
|
+
maxSize: 100000,
|
|
255
|
+
},
|
|
256
|
+
tools: [
|
|
257
|
+
{ name: 'search', description: 'Search the web' },
|
|
258
|
+
],
|
|
259
|
+
rateLimit: {
|
|
260
|
+
requestsPerMinute: 60,
|
|
261
|
+
tokensPerMinute: 100000,
|
|
262
|
+
},
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
expect(manifest.metadata.model?.provider).toBe('anthropic');
|
|
267
|
+
expect(manifest.metadata.memory?.type).toBe('session');
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
describe('MediaManifest type', () => {
|
|
272
|
+
it('should allow valid media manifest for images', () => {
|
|
273
|
+
const manifest: MediaManifest = {
|
|
274
|
+
kind: OriginalKind.Media,
|
|
275
|
+
name: 'profile-image',
|
|
276
|
+
version: '1.0.0',
|
|
277
|
+
resources: [{
|
|
278
|
+
id: 'image.png',
|
|
279
|
+
type: 'image',
|
|
280
|
+
contentType: 'image/png',
|
|
281
|
+
hash: 'img123',
|
|
282
|
+
}],
|
|
283
|
+
metadata: {
|
|
284
|
+
mediaType: 'image',
|
|
285
|
+
mimeType: 'image/png',
|
|
286
|
+
dimensions: {
|
|
287
|
+
width: 1920,
|
|
288
|
+
height: 1080,
|
|
289
|
+
aspectRatio: '16:9',
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
expect(manifest.metadata.mediaType).toBe('image');
|
|
295
|
+
expect(manifest.metadata.dimensions?.width).toBe(1920);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should allow video with full metadata', () => {
|
|
299
|
+
const manifest: MediaManifest = {
|
|
300
|
+
kind: OriginalKind.Media,
|
|
301
|
+
name: 'tutorial-video',
|
|
302
|
+
version: '1.0.0',
|
|
303
|
+
resources: [{
|
|
304
|
+
id: 'video.mp4',
|
|
305
|
+
type: 'video',
|
|
306
|
+
contentType: 'video/mp4',
|
|
307
|
+
hash: 'vid123',
|
|
308
|
+
}],
|
|
309
|
+
metadata: {
|
|
310
|
+
mediaType: 'video',
|
|
311
|
+
mimeType: 'video/mp4',
|
|
312
|
+
dimensions: {
|
|
313
|
+
width: 1920,
|
|
314
|
+
height: 1080,
|
|
315
|
+
},
|
|
316
|
+
duration: 300,
|
|
317
|
+
frameRate: 30,
|
|
318
|
+
audioChannels: 2,
|
|
319
|
+
codec: 'h264',
|
|
320
|
+
bitrate: 5000,
|
|
321
|
+
thumbnail: 'thumb.jpg',
|
|
322
|
+
altText: 'Tutorial on using the SDK',
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
expect(manifest.metadata.duration).toBe(300);
|
|
327
|
+
expect(manifest.metadata.frameRate).toBe(30);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('DocumentManifest type', () => {
|
|
332
|
+
it('should allow valid document manifest', () => {
|
|
333
|
+
const manifest: DocumentManifest = {
|
|
334
|
+
kind: OriginalKind.Document,
|
|
335
|
+
name: 'readme',
|
|
336
|
+
version: '1.0.0',
|
|
337
|
+
resources: [{
|
|
338
|
+
id: 'README.md',
|
|
339
|
+
type: 'document',
|
|
340
|
+
contentType: 'text/markdown',
|
|
341
|
+
hash: 'doc123',
|
|
342
|
+
}],
|
|
343
|
+
metadata: {
|
|
344
|
+
format: 'markdown',
|
|
345
|
+
content: 'README.md',
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
expect(manifest.metadata.format).toBe('markdown');
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('should allow full document metadata', () => {
|
|
353
|
+
const manifest: DocumentManifest = {
|
|
354
|
+
kind: OriginalKind.Document,
|
|
355
|
+
name: 'whitepaper',
|
|
356
|
+
version: '1.0.0',
|
|
357
|
+
resources: [{
|
|
358
|
+
id: 'paper.pdf',
|
|
359
|
+
type: 'document',
|
|
360
|
+
contentType: 'application/pdf',
|
|
361
|
+
hash: 'pdf123',
|
|
362
|
+
}],
|
|
363
|
+
metadata: {
|
|
364
|
+
format: 'pdf',
|
|
365
|
+
content: 'paper.pdf',
|
|
366
|
+
language: 'en',
|
|
367
|
+
pageCount: 42,
|
|
368
|
+
wordCount: 15000,
|
|
369
|
+
readingTime: 60,
|
|
370
|
+
keywords: ['blockchain', 'digital assets'],
|
|
371
|
+
abstract: 'This paper describes...',
|
|
372
|
+
toc: [
|
|
373
|
+
{ title: 'Introduction', level: 1, anchor: 'intro' },
|
|
374
|
+
{ title: 'Background', level: 1, anchor: 'bg' },
|
|
375
|
+
],
|
|
376
|
+
references: [
|
|
377
|
+
{ id: 'ref1', title: 'Bitcoin Whitepaper', year: 2008 },
|
|
378
|
+
],
|
|
379
|
+
status: 'published',
|
|
380
|
+
revision: 3,
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
expect(manifest.metadata.pageCount).toBe(42);
|
|
385
|
+
expect(manifest.metadata.status).toBe('published');
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
describe('Generic OriginalManifest', () => {
|
|
390
|
+
it('should work with any kind', () => {
|
|
391
|
+
function processManifest<K extends OriginalKind>(manifest: OriginalManifest<K>): string {
|
|
392
|
+
return `Processing ${manifest.name} v${manifest.version} (${manifest.kind})`;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const appManifest: AppManifest = {
|
|
396
|
+
kind: OriginalKind.App,
|
|
397
|
+
name: 'test-app',
|
|
398
|
+
version: '1.0.0',
|
|
399
|
+
resources: [],
|
|
400
|
+
metadata: { runtime: 'node', entrypoint: 'index.js' }
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const result = processManifest(appManifest);
|
|
404
|
+
expect(result).toContain('test-app');
|
|
405
|
+
expect(result).toContain('1.0.0');
|
|
406
|
+
expect(result).toContain('originals:kind:app');
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
|