digital-products 2.1.3 → 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 (122) hide show
  1. package/CHANGELOG.md +9 -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 +29 -13
  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/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
package/src/app.js DELETED
@@ -1,106 +0,0 @@
1
- /**
2
- * App() - Define an application
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create an application definition
7
- *
8
- * @example
9
- * ```ts
10
- * const myApp = App({
11
- * id: 'my-app',
12
- * name: 'My App',
13
- * description: 'A web application',
14
- * version: '1.0.0',
15
- * framework: 'react',
16
- * routes: [
17
- * { path: '/', component: 'Home' },
18
- * { path: '/about', component: 'About' },
19
- * { path: '/users/:id', component: 'UserDetail' },
20
- * ],
21
- * state: {
22
- * library: 'zustand',
23
- * schema: {
24
- * user: 'Current user object',
25
- * settings: 'App settings object',
26
- * },
27
- * },
28
- * auth: {
29
- * provider: 'clerk',
30
- * protectedRoutes: ['/dashboard', '/profile'],
31
- * },
32
- * })
33
- * ```
34
- */
35
- export function App(config) {
36
- const app = {
37
- type: 'app',
38
- id: config.id,
39
- name: config.name,
40
- description: config.description,
41
- version: config.version,
42
- framework: config.framework || 'react',
43
- routes: config.routes || [],
44
- config: config.config,
45
- state: config.state,
46
- auth: config.auth,
47
- deployments: config.deployments,
48
- metadata: config.metadata,
49
- tags: config.tags,
50
- status: config.status || 'active',
51
- };
52
- return registerProduct(app);
53
- }
54
- /**
55
- * Helper to create a route definition
56
- *
57
- * @example
58
- * ```ts
59
- * const userRoute = Route('/users/:id', 'UserDetail', {
60
- * meta: { title: 'User Profile' },
61
- * })
62
- * ```
63
- */
64
- export function Route(path, component, options) {
65
- return {
66
- path,
67
- component,
68
- ...options,
69
- };
70
- }
71
- /**
72
- * Helper to configure state management
73
- *
74
- * @example
75
- * ```ts
76
- * const state = State({
77
- * library: 'zustand',
78
- * schema: {
79
- * user: 'Current user',
80
- * settings: 'User settings',
81
- * },
82
- * persistence: {
83
- * type: 'local',
84
- * key: 'app-state',
85
- * },
86
- * })
87
- * ```
88
- */
89
- export function State(config) {
90
- return config;
91
- }
92
- /**
93
- * Helper to configure authentication
94
- *
95
- * @example
96
- * ```ts
97
- * const auth = Auth({
98
- * provider: 'clerk',
99
- * protectedRoutes: ['/dashboard', '/profile'],
100
- * roles: ['admin', 'user'],
101
- * })
102
- * ```
103
- */
104
- export function Auth(config) {
105
- return config;
106
- }
package/src/content.js DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * Content() - Define content
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create a content definition
7
- *
8
- * @example
9
- * ```ts
10
- * const blogContent = Content({
11
- * id: 'blog',
12
- * name: 'Blog Posts',
13
- * description: 'Blog content for the website',
14
- * version: '1.0.0',
15
- * format: 'mdx',
16
- * source: './content/blog',
17
- * frontmatter: {
18
- * title: 'Post title',
19
- * author: 'Author name',
20
- * date: 'Publication date (date)',
21
- * tags: ['Array of tags'],
22
- * },
23
- * categories: ['Technology', 'Business', 'Design'],
24
- * workflow: Workflow({
25
- * states: ['draft', 'review', 'published'],
26
- * initialState: 'draft',
27
- * transitions: [
28
- * { from: 'draft', to: 'review', action: 'submit' },
29
- * { from: 'review', to: 'published', action: 'approve' },
30
- * { from: 'review', to: 'draft', action: 'reject' },
31
- * ],
32
- * }),
33
- * })
34
- * ```
35
- */
36
- export function Content(config) {
37
- const content = {
38
- type: 'content',
39
- id: config.id,
40
- name: config.name,
41
- description: config.description,
42
- version: config.version,
43
- format: config.format || 'markdown',
44
- source: config.source,
45
- schema: config.schema,
46
- frontmatter: config.frontmatter,
47
- categories: config.categories,
48
- workflow: config.workflow,
49
- metadata: config.metadata,
50
- tags: config.tags,
51
- status: config.status || 'active',
52
- };
53
- return registerProduct(content);
54
- }
55
- /**
56
- * Helper to create a workflow definition
57
- *
58
- * @example
59
- * ```ts
60
- * const workflow = Workflow({
61
- * states: ['draft', 'review', 'published', 'archived'],
62
- * initialState: 'draft',
63
- * transitions: [
64
- * { from: 'draft', to: 'review', action: 'submit' },
65
- * { from: 'review', to: 'published', action: 'approve' },
66
- * { from: 'review', to: 'draft', action: 'reject' },
67
- * { from: 'published', to: 'archived', action: 'archive' },
68
- * ],
69
- * approvals: [
70
- * { state: 'review', roles: ['editor', 'admin'] },
71
- * ],
72
- * })
73
- * ```
74
- */
75
- export function Workflow(config) {
76
- return config;
77
- }
package/src/data.js DELETED
@@ -1,106 +0,0 @@
1
- /**
2
- * Data() - Define structured data
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create a data definition
7
- *
8
- * @example
9
- * ```ts
10
- * const userData = Data({
11
- * id: 'users',
12
- * name: 'Users',
13
- * description: 'User data store',
14
- * version: '1.0.0',
15
- * schema: {
16
- * id: 'User ID',
17
- * name: 'User name',
18
- * email: 'User email',
19
- * createdAt: 'Creation timestamp (date)',
20
- * role: 'admin | user | guest',
21
- * },
22
- * provider: 'postgres',
23
- * indexes: [
24
- * Index('email_idx', ['email'], { unique: true }),
25
- * Index('role_idx', ['role']),
26
- * ],
27
- * validation: [
28
- * Validate('email', 'email', 'Must be a valid email'),
29
- * Validate('name', 'required', 'Name is required'),
30
- * ],
31
- * })
32
- * ```
33
- */
34
- export function Data(config) {
35
- const data = {
36
- type: 'data',
37
- id: config.id,
38
- name: config.name,
39
- description: config.description,
40
- version: config.version,
41
- schema: config.schema,
42
- provider: config.provider || 'fs',
43
- indexes: config.indexes,
44
- relationships: config.relationships,
45
- validation: config.validation,
46
- metadata: config.metadata,
47
- tags: config.tags,
48
- status: config.status || 'active',
49
- };
50
- return registerProduct(data);
51
- }
52
- /**
53
- * Helper to create an index definition
54
- *
55
- * @example
56
- * ```ts
57
- * const emailIndex = Index('email_idx', ['email'], { unique: true })
58
- * const nameIndex = Index('name_idx', ['firstName', 'lastName'])
59
- * const vectorIndex = Index('embedding_idx', ['embedding'], { type: 'vector' })
60
- * ```
61
- */
62
- export function Index(name, fields, options) {
63
- return {
64
- name,
65
- fields,
66
- ...options,
67
- };
68
- }
69
- /**
70
- * Helper to create a relationship definition
71
- *
72
- * @example
73
- * ```ts
74
- * const userPosts = Relationship('one-to-many', 'userId', 'posts', 'author')
75
- * const postTags = Relationship('many-to-many', 'postId', 'tags', 'posts')
76
- * ```
77
- */
78
- export function Relationship(type, from, to, field) {
79
- return {
80
- type,
81
- from,
82
- to,
83
- field,
84
- };
85
- }
86
- /**
87
- * Helper to create a validation rule
88
- *
89
- * @example
90
- * ```ts
91
- * const emailRule = Validate('email', 'email', 'Must be a valid email')
92
- * const ageRule = Validate('age', 'min', { value: 18 }, 'Must be 18 or older')
93
- * const uniqueRule = Validate('username', 'unique', 'Username already taken')
94
- * ```
95
- */
96
- export function Validate(field, rule, paramsOrMessage, message) {
97
- if (typeof paramsOrMessage === 'string') {
98
- return { field, rule, message: paramsOrMessage };
99
- }
100
- return {
101
- field,
102
- rule,
103
- params: paramsOrMessage,
104
- message,
105
- };
106
- }
package/src/dataset.js DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * Dataset() - Define a dataset
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create a dataset definition
7
- *
8
- * @example
9
- * ```ts
10
- * const movieDataset = Dataset({
11
- * id: 'movies',
12
- * name: 'Movie Database',
13
- * description: 'Comprehensive movie information dataset',
14
- * version: '2024.1',
15
- * format: 'parquet',
16
- * schema: {
17
- * id: 'Movie ID',
18
- * title: 'Movie title',
19
- * year: 'Release year (number)',
20
- * genres: ['Array of genre names'],
21
- * rating: 'Average rating (number)',
22
- * votes: 'Number of votes (number)',
23
- * },
24
- * source: 's3://datasets/movies.parquet',
25
- * size: 1000000,
26
- * license: 'CC-BY-4.0',
27
- * updateFrequency: 'daily',
28
- * })
29
- * ```
30
- */
31
- export function Dataset(config) {
32
- const dataset = {
33
- type: 'dataset',
34
- id: config.id,
35
- name: config.name,
36
- description: config.description,
37
- version: config.version,
38
- format: config.format || 'json',
39
- schema: config.schema,
40
- source: config.source,
41
- size: config.size,
42
- license: config.license,
43
- updateFrequency: config.updateFrequency || 'static',
44
- metadata: config.metadata,
45
- tags: config.tags,
46
- status: config.status || 'active',
47
- };
48
- return registerProduct(dataset);
49
- }