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.
Files changed (80) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -0
  3. package/dist/api.js +7 -7
  4. package/dist/api.js.map +1 -1
  5. package/dist/app.js +6 -6
  6. package/dist/app.js.map +1 -1
  7. package/dist/client.d.ts +157 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +69 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/content.js +7 -7
  12. package/dist/content.js.map +1 -1
  13. package/dist/data.d.ts.map +1 -1
  14. package/dist/data.js +6 -6
  15. package/dist/data.js.map +1 -1
  16. package/dist/dataset.js +5 -5
  17. package/dist/dataset.js.map +1 -1
  18. package/dist/index.d.ts +92 -13
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +139 -15
  21. package/dist/index.js.map +1 -1
  22. package/dist/mcp.d.ts +1 -1
  23. package/dist/mcp.d.ts.map +1 -1
  24. package/dist/mcp.js +17 -10
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/product.js +2 -2
  27. package/dist/product.js.map +1 -1
  28. package/dist/sdk.d.ts.map +1 -1
  29. package/dist/sdk.js +52 -16
  30. package/dist/sdk.js.map +1 -1
  31. package/dist/site.d.ts.map +1 -1
  32. package/dist/site.js +12 -8
  33. package/dist/site.js.map +1 -1
  34. package/dist/types.d.ts +830 -12
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js +495 -2
  37. package/dist/types.js.map +1 -1
  38. package/dist/worker.d.ts +205 -0
  39. package/dist/worker.d.ts.map +1 -0
  40. package/dist/worker.js +356 -0
  41. package/dist/worker.js.map +1 -0
  42. package/package.json +20 -4
  43. package/src/api.ts +7 -7
  44. package/src/app.ts +6 -6
  45. package/src/client.ts +192 -0
  46. package/src/content.ts +7 -7
  47. package/src/data.ts +12 -7
  48. package/src/dataset.ts +5 -5
  49. package/src/index.ts +151 -15
  50. package/src/mcp.ts +18 -11
  51. package/src/product.ts +2 -2
  52. package/src/sdk.ts +54 -15
  53. package/src/site.ts +12 -8
  54. package/src/types.ts +821 -12
  55. package/src/worker.ts +525 -0
  56. package/test/product.test.ts +53 -198
  57. package/test/unified-types.test.ts +589 -0
  58. package/test/worker.test.ts +912 -0
  59. package/vitest.config.ts +42 -0
  60. package/wrangler.jsonc +36 -0
  61. package/.turbo/turbo-build.log +0 -5
  62. package/src/api.js +0 -128
  63. package/src/app.js +0 -106
  64. package/src/content.js +0 -77
  65. package/src/data.js +0 -106
  66. package/src/dataset.js +0 -49
  67. package/src/entities/ai.js +0 -858
  68. package/src/entities/content.js +0 -783
  69. package/src/entities/index.js +0 -88
  70. package/src/entities/interfaces.js +0 -929
  71. package/src/entities/lifecycle.js +0 -803
  72. package/src/entities/products.js +0 -797
  73. package/src/entities/web.js +0 -657
  74. package/src/index.js +0 -35
  75. package/src/mcp.js +0 -139
  76. package/src/product.js +0 -53
  77. package/src/registry.js +0 -31
  78. package/src/sdk.js +0 -127
  79. package/src/site.js +0 -112
  80. package/src/types.js +0 -4
@@ -1,200 +1,55 @@
1
- /**
2
- * Tests for Product functionality
3
- *
4
- * Covers product creation and registration.
5
- */
6
-
7
- import { describe, it, expect, beforeEach } from 'vitest'
8
- import { Product, createProduct, registerProduct, registry } from '../src/index.js'
9
-
10
- describe('Product', () => {
11
- beforeEach(() => {
12
- registry.clear()
13
- })
14
-
15
- describe('Product creation', () => {
16
- it('creates a product with basic config', () => {
17
- const product = Product({
18
- id: 'my-product',
19
- name: 'My Product',
20
- description: 'A digital product',
21
- version: '1.0.0',
22
- })
23
-
24
- expect(product.id).toBe('my-product')
25
- expect(product.name).toBe('My Product')
26
- expect(product.description).toBe('A digital product')
27
- expect(product.version).toBe('1.0.0')
28
- })
29
-
30
- it('defaults status to active', () => {
31
- const product = Product({
32
- id: 'test',
33
- name: 'Test',
34
- description: 'Test product',
35
- version: '1.0.0',
36
- })
37
-
38
- expect(product.status).toBe('active')
39
- })
40
-
41
- it('allows custom status', () => {
42
- const product = Product({
43
- id: 'test',
44
- name: 'Test',
45
- description: 'Test product',
46
- version: '1.0.0',
47
- status: 'deprecated',
48
- })
49
-
50
- expect(product.status).toBe('deprecated')
51
- })
52
-
53
- it('supports metadata', () => {
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
  })