digital-products 2.1.3 → 2.4.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 (122) hide show
  1. package/.turbo/turbo-build.log +4 -5
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +2 -0
  4. package/dist/api.js +7 -7
  5. package/dist/api.js.map +1 -1
  6. package/dist/app.js +6 -6
  7. package/dist/app.js.map +1 -1
  8. package/dist/client.d.ts +157 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +69 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/content.js +7 -7
  13. package/dist/content.js.map +1 -1
  14. package/dist/data.d.ts.map +1 -1
  15. package/dist/data.js +6 -6
  16. package/dist/data.js.map +1 -1
  17. package/dist/dataset.js +5 -5
  18. package/dist/dataset.js.map +1 -1
  19. package/dist/index.d.ts +92 -13
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +139 -15
  22. package/dist/index.js.map +1 -1
  23. package/dist/mcp.d.ts +1 -1
  24. package/dist/mcp.d.ts.map +1 -1
  25. package/dist/mcp.js +17 -10
  26. package/dist/mcp.js.map +1 -1
  27. package/dist/product.js +2 -2
  28. package/dist/product.js.map +1 -1
  29. package/dist/sdk.d.ts.map +1 -1
  30. package/dist/sdk.js +52 -16
  31. package/dist/sdk.js.map +1 -1
  32. package/dist/site.d.ts.map +1 -1
  33. package/dist/site.js +12 -8
  34. package/dist/site.js.map +1 -1
  35. package/dist/types.d.ts +830 -12
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/types.js +495 -2
  38. package/dist/types.js.map +1 -1
  39. package/dist/worker.d.ts +205 -0
  40. package/dist/worker.d.ts.map +1 -0
  41. package/dist/worker.js +356 -0
  42. package/dist/worker.js.map +1 -0
  43. package/package.json +29 -13
  44. package/src/api.ts +7 -7
  45. package/src/app.ts +6 -6
  46. package/src/client.ts +192 -0
  47. package/src/content.ts +7 -7
  48. package/src/data.ts +12 -7
  49. package/src/dataset.ts +5 -5
  50. package/src/index.ts +151 -15
  51. package/src/mcp.ts +18 -11
  52. package/src/product.ts +2 -2
  53. package/src/sdk.ts +54 -15
  54. package/src/site.ts +12 -8
  55. package/src/types.ts +821 -12
  56. package/src/worker.ts +525 -0
  57. package/test/product.test.ts +53 -198
  58. package/test/unified-types.test.ts +589 -0
  59. package/test/worker.test.ts +912 -0
  60. package/vitest.config.ts +42 -0
  61. package/wrangler.jsonc +36 -0
  62. package/LICENSE +0 -21
  63. package/dist/features/define.d.ts +0 -63
  64. package/dist/features/define.d.ts.map +0 -1
  65. package/dist/features/define.js +0 -72
  66. package/dist/features/define.js.map +0 -1
  67. package/dist/features/flags.d.ts +0 -98
  68. package/dist/features/flags.d.ts.map +0 -1
  69. package/dist/features/flags.js +0 -145
  70. package/dist/features/flags.js.map +0 -1
  71. package/dist/features/toggles.d.ts +0 -75
  72. package/dist/features/toggles.d.ts.map +0 -1
  73. package/dist/features/toggles.js +0 -107
  74. package/dist/features/toggles.js.map +0 -1
  75. package/dist/tiers/define.d.ts +0 -63
  76. package/dist/tiers/define.d.ts.map +0 -1
  77. package/dist/tiers/define.js +0 -78
  78. package/dist/tiers/define.js.map +0 -1
  79. package/dist/tiers/entitlements.d.ts +0 -94
  80. package/dist/tiers/entitlements.d.ts.map +0 -1
  81. package/dist/tiers/entitlements.js +0 -94
  82. package/dist/tiers/entitlements.js.map +0 -1
  83. package/src/api.js +0 -128
  84. package/src/app.js +0 -106
  85. package/src/content.js +0 -77
  86. package/src/data.js +0 -106
  87. package/src/dataset.js +0 -49
  88. package/src/entities/ai.js +0 -858
  89. package/src/entities/content.js +0 -783
  90. package/src/entities/index.js +0 -88
  91. package/src/entities/interfaces.js +0 -929
  92. package/src/entities/lifecycle.js +0 -803
  93. package/src/entities/products.js +0 -797
  94. package/src/entities/web.js +0 -657
  95. package/src/features/define.ts +0 -130
  96. package/src/features/flags.ts +0 -247
  97. package/src/features/toggles.ts +0 -189
  98. package/src/index.js +0 -35
  99. package/src/mcp.js +0 -139
  100. package/src/pricing/billing.ts +0 -386
  101. package/src/pricing/plans.ts +0 -214
  102. package/src/product.js +0 -53
  103. package/src/registry.js +0 -31
  104. package/src/sdk.js +0 -127
  105. package/src/site.js +0 -112
  106. package/src/tiers/define.ts +0 -137
  107. package/src/tiers/entitlements.ts +0 -201
  108. package/src/types.js +0 -4
  109. package/test/analytics/events.test.ts +0 -319
  110. package/test/analytics/experiments.test.ts +0 -327
  111. package/test/features/define.test.ts +0 -187
  112. package/test/features/flags.test.ts +0 -259
  113. package/test/features/toggles.test.ts +0 -178
  114. package/test/lifecycle/stages.test.ts +0 -233
  115. package/test/lifecycle/transitions.test.ts +0 -207
  116. package/test/onboarding/flows.test.ts +0 -307
  117. package/test/pricing/billing.test.ts +0 -287
  118. package/test/pricing/plans.test.ts +0 -307
  119. package/test/roadmap/milestones.test.ts +0 -231
  120. package/test/roadmap/priorities.test.ts +0 -239
  121. package/test/tiers/define.test.ts +0 -192
  122. package/test/tiers/entitlements.test.ts +0 -220
@@ -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
  })