digital-products 2.1.1 → 2.3.0
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/CHANGELOG.md +17 -0
- package/README.md +2 -0
- package/dist/api.js +7 -7
- package/dist/api.js.map +1 -1
- package/dist/app.js +6 -6
- package/dist/app.js.map +1 -1
- package/dist/client.d.ts +157 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -0
- package/dist/content.js +7 -7
- package/dist/content.js.map +1 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +6 -6
- package/dist/data.js.map +1 -1
- package/dist/dataset.js +5 -5
- package/dist/dataset.js.map +1 -1
- package/dist/index.d.ts +92 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +139 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +17 -10
- package/dist/mcp.js.map +1 -1
- package/dist/product.js +2 -2
- package/dist/product.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +52 -16
- package/dist/sdk.js.map +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +12 -8
- package/dist/site.js.map +1 -1
- package/dist/types.d.ts +830 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +495 -2
- package/dist/types.js.map +1 -1
- package/dist/worker.d.ts +205 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +356 -0
- package/dist/worker.js.map +1 -0
- package/package.json +20 -4
- package/src/api.ts +7 -7
- package/src/app.ts +6 -6
- package/src/client.ts +192 -0
- package/src/content.ts +7 -7
- package/src/data.ts +12 -7
- package/src/dataset.ts +5 -5
- package/src/index.ts +151 -15
- package/src/mcp.ts +18 -11
- package/src/product.ts +2 -2
- package/src/sdk.ts +54 -15
- package/src/site.ts +12 -8
- package/src/types.ts +821 -12
- package/src/worker.ts +525 -0
- package/test/product.test.ts +53 -198
- package/test/unified-types.test.ts +589 -0
- package/test/worker.test.ts +912 -0
- package/vitest.config.ts +42 -0
- package/wrangler.jsonc +36 -0
- package/.turbo/turbo-build.log +0 -5
- package/src/api.js +0 -128
- package/src/app.js +0 -106
- package/src/content.js +0 -77
- package/src/data.js +0 -106
- package/src/dataset.js +0 -49
- package/src/entities/ai.js +0 -858
- package/src/entities/content.js +0 -783
- package/src/entities/index.js +0 -88
- package/src/entities/interfaces.js +0 -929
- package/src/entities/lifecycle.js +0 -803
- package/src/entities/products.js +0 -797
- package/src/entities/web.js +0 -657
- package/src/index.js +0 -35
- package/src/mcp.js +0 -139
- package/src/product.js +0 -53
- package/src/registry.js +0 -31
- package/src/sdk.js +0 -127
- package/src/site.js +0 -112
- package/src/types.js +0 -4
package/test/product.test.ts
CHANGED
|
@@ -1,200 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const product = Product({
|
|
55
|
-
id: 'test',
|
|
56
|
-
name: 'Test',
|
|
57
|
-
description: 'Test product',
|
|
58
|
-
version: '1.0.0',
|
|
59
|
-
metadata: { author: 'John', license: 'MIT' },
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
expect(product.metadata).toEqual({ author: 'John', license: 'MIT' })
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('supports tags', () => {
|
|
66
|
-
const product = Product({
|
|
67
|
-
id: 'test',
|
|
68
|
-
name: 'Test',
|
|
69
|
-
description: 'Test product',
|
|
70
|
-
version: '1.0.0',
|
|
71
|
-
tags: ['api', 'production'],
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
expect(product.tags).toEqual(['api', 'production'])
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
describe('createProduct', () => {
|
|
79
|
-
it('creates a product', () => {
|
|
80
|
-
const product = createProduct({
|
|
81
|
-
id: 'created-product',
|
|
82
|
-
name: 'Created Product',
|
|
83
|
-
description: 'A created product',
|
|
84
|
-
version: '1.0.0',
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
expect(product.id).toBe('created-product')
|
|
88
|
-
expect(product.name).toBe('Created Product')
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
describe('registerProduct', () => {
|
|
93
|
-
it('registers a product in the registry', () => {
|
|
94
|
-
const product = Product({
|
|
95
|
-
id: 'registered-product',
|
|
96
|
-
name: 'Registered',
|
|
97
|
-
description: 'Registered product',
|
|
98
|
-
version: '1.0.0',
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
registerProduct(product)
|
|
102
|
-
|
|
103
|
-
expect(registry.get('registered-product')).toBeDefined()
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it('returns the registered product', () => {
|
|
107
|
-
const product = Product({
|
|
108
|
-
id: 'returned-product',
|
|
109
|
-
name: 'Returned',
|
|
110
|
-
description: 'Returned product',
|
|
111
|
-
version: '1.0.0',
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
const result = registerProduct(product)
|
|
115
|
-
|
|
116
|
-
expect(result).toBe(product)
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
describe('Registry', () => {
|
|
122
|
-
beforeEach(() => {
|
|
123
|
-
registry.clear()
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
describe('register', () => {
|
|
127
|
-
it('adds a product to the registry', () => {
|
|
128
|
-
const product = Product({
|
|
129
|
-
id: 'test-product',
|
|
130
|
-
name: 'Test',
|
|
131
|
-
description: 'Test',
|
|
132
|
-
version: '1.0.0',
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
registerProduct(product)
|
|
136
|
-
|
|
137
|
-
expect(registry.get('test-product')).toEqual(product)
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
describe('get', () => {
|
|
142
|
-
it('returns product by id', () => {
|
|
143
|
-
const product = Product({
|
|
144
|
-
id: 'get-test',
|
|
145
|
-
name: 'Get Test',
|
|
146
|
-
description: 'Test',
|
|
147
|
-
version: '1.0.0',
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
registerProduct(product)
|
|
151
|
-
|
|
152
|
-
expect(registry.get('get-test')?.name).toBe('Get Test')
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
it('returns undefined for non-existent id', () => {
|
|
156
|
-
expect(registry.get('non-existent')).toBeUndefined()
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
describe('list', () => {
|
|
161
|
-
it('returns all products', () => {
|
|
162
|
-
registerProduct(Product({ id: 'p1', name: 'P1', description: 'D1', version: '1.0.0' }))
|
|
163
|
-
registerProduct(Product({ id: 'p2', name: 'P2', description: 'D2', version: '1.0.0' }))
|
|
164
|
-
|
|
165
|
-
const products = registry.list()
|
|
166
|
-
|
|
167
|
-
expect(products).toHaveLength(2)
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('returns empty array when no products', () => {
|
|
171
|
-
expect(registry.list()).toHaveLength(0)
|
|
172
|
-
})
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
describe('remove', () => {
|
|
176
|
-
it('removes a product from the registry', () => {
|
|
177
|
-
registerProduct(Product({ id: 'to-remove', name: 'Remove', description: 'D', version: '1.0.0' }))
|
|
178
|
-
|
|
179
|
-
const result = registry.remove('to-remove')
|
|
180
|
-
|
|
181
|
-
expect(result).toBe(true)
|
|
182
|
-
expect(registry.get('to-remove')).toBeUndefined()
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
it('returns false for non-existent product', () => {
|
|
186
|
-
expect(registry.remove('non-existent')).toBe(false)
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
describe('clear', () => {
|
|
191
|
-
it('removes all products', () => {
|
|
192
|
-
registerProduct(Product({ id: 'p1', name: 'P1', description: 'D1', version: '1.0.0' }))
|
|
193
|
-
registerProduct(Product({ id: 'p2', name: 'P2', description: 'D2', version: '1.0.0' }))
|
|
194
|
-
|
|
195
|
-
registry.clear()
|
|
196
|
-
|
|
197
|
-
expect(registry.list()).toHaveLength(0)
|
|
198
|
-
})
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import type { Product, App, API, Site } from '../src/types'
|
|
3
|
+
|
|
4
|
+
describe('Product types', () => {
|
|
5
|
+
it('Product has required properties', () => {
|
|
6
|
+
const product: Product = {
|
|
7
|
+
$id: 'https://schema.org.ai/products/p1',
|
|
8
|
+
$type: 'https://schema.org.ai/Product',
|
|
9
|
+
name: 'Test Product',
|
|
10
|
+
description: 'A digital product',
|
|
11
|
+
status: 'active',
|
|
12
|
+
}
|
|
13
|
+
expect(product.$type).toBe('https://schema.org.ai/Product')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('App extends Product with app-specific properties', () => {
|
|
17
|
+
const app: App = {
|
|
18
|
+
$id: 'https://schema.org.ai/apps/a1',
|
|
19
|
+
$type: 'https://schema.org.ai/App',
|
|
20
|
+
name: 'My App',
|
|
21
|
+
description: 'A web application',
|
|
22
|
+
status: 'active',
|
|
23
|
+
platform: 'web',
|
|
24
|
+
url: 'https://myapp.com',
|
|
25
|
+
}
|
|
26
|
+
expect(app.$type).toBe('https://schema.org.ai/App')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('API extends Product with endpoint info', () => {
|
|
30
|
+
const api: API = {
|
|
31
|
+
$id: 'https://schema.org.ai/apis/a1',
|
|
32
|
+
$type: 'https://schema.org.ai/API',
|
|
33
|
+
name: 'My API',
|
|
34
|
+
description: 'REST API',
|
|
35
|
+
status: 'active',
|
|
36
|
+
baseUrl: 'https://api.myapp.com',
|
|
37
|
+
version: 'v1',
|
|
38
|
+
authentication: 'bearer',
|
|
39
|
+
}
|
|
40
|
+
expect(api.$type).toBe('https://schema.org.ai/API')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('Site extends Product with website properties', () => {
|
|
44
|
+
const site: Site = {
|
|
45
|
+
$id: 'https://schema.org.ai/sites/s1',
|
|
46
|
+
$type: 'https://schema.org.ai/Site',
|
|
47
|
+
name: 'My Site',
|
|
48
|
+
description: 'Marketing website',
|
|
49
|
+
status: 'active',
|
|
50
|
+
url: 'https://mysite.com',
|
|
51
|
+
siteType: 'marketing',
|
|
52
|
+
}
|
|
53
|
+
expect(site.$type).toBe('https://schema.org.ai/Site')
|
|
199
54
|
})
|
|
200
55
|
})
|