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
package/src/mcp.js DELETED
@@ -1,139 +0,0 @@
1
- /**
2
- * MCP() - Define a Model Context Protocol server
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create an MCP server definition
7
- *
8
- * @example
9
- * ```ts
10
- * const mcpServer = MCP({
11
- * id: 'my-mcp',
12
- * name: 'My MCP Server',
13
- * description: 'Custom MCP server for AI tools',
14
- * version: '1.0.0',
15
- * transport: 'stdio',
16
- * tools: [
17
- * Tool('searchFiles', 'Search for files in the project', {
18
- * query: 'Search query',
19
- * path: 'Directory to search in',
20
- * }),
21
- * Tool('readFile', 'Read file contents', {
22
- * path: 'File path to read',
23
- * }),
24
- * ],
25
- * resources: [
26
- * Resource('file://', 'Project Files', 'Access to project files'),
27
- * ],
28
- * prompts: [
29
- * Prompt('codeReview', 'Review code for best practices',
30
- * 'Review the following code:\n\n{{code}}'),
31
- * ],
32
- * })
33
- * ```
34
- */
35
- export function MCP(config) {
36
- const mcp = {
37
- type: 'mcp',
38
- id: config.id,
39
- name: config.name,
40
- description: config.description,
41
- version: config.version,
42
- transport: config.transport,
43
- tools: config.tools,
44
- resources: config.resources,
45
- prompts: config.prompts,
46
- config: config.config,
47
- metadata: config.metadata,
48
- tags: config.tags,
49
- status: config.status || 'active',
50
- };
51
- return registerProduct(mcp);
52
- }
53
- /**
54
- * Helper to create an MCP tool
55
- *
56
- * @example
57
- * ```ts
58
- * const tool = Tool(
59
- * 'searchCode',
60
- * 'Search code using regex',
61
- * {
62
- * pattern: 'Regex pattern to search for',
63
- * path: 'Directory to search in',
64
- * },
65
- * async (input) => {
66
- * // Tool implementation
67
- * return { matches: [] }
68
- * }
69
- * )
70
- * ```
71
- */
72
- export function Tool(name, description, inputSchema, handler) {
73
- return {
74
- name,
75
- description,
76
- inputSchema,
77
- handler,
78
- };
79
- }
80
- /**
81
- * Helper to create an MCP resource
82
- *
83
- * @example
84
- * ```ts
85
- * const resource = Resource(
86
- * 'file://project',
87
- * 'Project Files',
88
- * 'Access to all project files',
89
- * 'application/json'
90
- * )
91
- * ```
92
- */
93
- export function Resource(uri, name, description, mimeType) {
94
- return {
95
- uri,
96
- name,
97
- description,
98
- mimeType,
99
- };
100
- }
101
- /**
102
- * Helper to create an MCP prompt
103
- *
104
- * @example
105
- * ```ts
106
- * const prompt = Prompt(
107
- * 'summarize',
108
- * 'Summarize text',
109
- * 'Summarize the following:\n\n{{text}}',
110
- * { text: 'Text to summarize' }
111
- * )
112
- * ```
113
- */
114
- export function Prompt(name, description, template, args) {
115
- return {
116
- name,
117
- description,
118
- template,
119
- arguments: args,
120
- };
121
- }
122
- /**
123
- * Helper to configure MCP server
124
- *
125
- * @example
126
- * ```ts
127
- * const config = MCPConfig({
128
- * port: 3000,
129
- * host: 'localhost',
130
- * auth: {
131
- * type: 'bearer',
132
- * token: process.env.MCP_TOKEN,
133
- * },
134
- * })
135
- * ```
136
- */
137
- export function MCPConfig(config) {
138
- return config;
139
- }
package/src/product.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * Generic Product() constructor
3
- */
4
- import { registry } from './registry.js';
5
- /**
6
- * Create a generic digital product definition
7
- *
8
- * @example
9
- * ```ts
10
- * const product = Product({
11
- * id: 'my-product',
12
- * name: 'My Product',
13
- * description: 'A digital product',
14
- * version: '1.0.0',
15
- * })
16
- * ```
17
- */
18
- export function Product(config) {
19
- const product = {
20
- id: config.id,
21
- name: config.name,
22
- description: config.description,
23
- version: config.version,
24
- metadata: config.metadata,
25
- tags: config.tags,
26
- status: config.status || 'active',
27
- };
28
- return product;
29
- }
30
- /**
31
- * Create and register a product in one step
32
- *
33
- * @example
34
- * ```ts
35
- * const product = createProduct({
36
- * id: 'my-product',
37
- * name: 'My Product',
38
- * description: 'A digital product',
39
- * version: '1.0.0',
40
- * })
41
- * ```
42
- */
43
- export function createProduct(config) {
44
- const product = Product(config);
45
- return product;
46
- }
47
- /**
48
- * Create and register any product definition
49
- */
50
- export function registerProduct(product) {
51
- registry.register(product);
52
- return product;
53
- }
package/src/registry.js DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Product registry implementation
3
- */
4
- /**
5
- * In-memory product registry
6
- */
7
- class InMemoryProductRegistry {
8
- products = new Map();
9
- register(product) {
10
- this.products.set(product.id, product);
11
- }
12
- get(id) {
13
- return this.products.get(id);
14
- }
15
- list() {
16
- return Array.from(this.products.values());
17
- }
18
- listByType(type) {
19
- return this.list().filter((p) => p.type === type);
20
- }
21
- remove(id) {
22
- return this.products.delete(id);
23
- }
24
- clear() {
25
- this.products.clear();
26
- }
27
- }
28
- /**
29
- * Global product registry instance
30
- */
31
- export const registry = new InMemoryProductRegistry();
package/src/sdk.js DELETED
@@ -1,127 +0,0 @@
1
- /**
2
- * SDK() - Define a software development kit
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create an SDK definition
7
- *
8
- * @example
9
- * ```ts
10
- * const mySDK = SDK({
11
- * id: 'my-sdk',
12
- * name: 'My SDK',
13
- * description: 'JavaScript SDK for My API',
14
- * version: '1.0.0',
15
- * language: 'typescript',
16
- * api: 'my-api',
17
- * exports: [
18
- * Export('function', 'createClient', 'Create an API client', {
19
- * parameters: {
20
- * apiKey: 'API key for authentication',
21
- * baseUrl: 'Optional base URL',
22
- * },
23
- * returns: 'API client instance',
24
- * }),
25
- * Export('class', 'APIClient', 'Main API client', {
26
- * methods: [
27
- * Export('function', 'get', 'GET request', {
28
- * parameters: { path: 'Request path' },
29
- * returns: 'Response data',
30
- * }),
31
- * Export('function', 'post', 'POST request', {
32
- * parameters: { path: 'Request path', data: 'Request body' },
33
- * returns: 'Response data',
34
- * }),
35
- * ],
36
- * }),
37
- * ],
38
- * install: 'npm install my-sdk',
39
- * examples: [
40
- * Example(
41
- * 'Basic Usage',
42
- * 'Create a client and make a request',
43
- * `import { createClient } from 'my-sdk'
44
- *
45
- * const client = createClient({ apiKey: 'YOUR_API_KEY' })
46
- * const users = await client.get('/users')
47
- * console.log(users)`
48
- * ),
49
- * ],
50
- * })
51
- * ```
52
- */
53
- export function SDK(config) {
54
- const sdk = {
55
- type: 'sdk',
56
- id: config.id,
57
- name: config.name,
58
- description: config.description,
59
- version: config.version,
60
- language: config.language,
61
- api: config.api,
62
- exports: config.exports,
63
- install: config.install,
64
- docs: config.docs,
65
- examples: config.examples,
66
- metadata: config.metadata,
67
- tags: config.tags,
68
- status: config.status || 'active',
69
- };
70
- return registerProduct(sdk);
71
- }
72
- /**
73
- * Helper to create an SDK export
74
- *
75
- * @example
76
- * ```ts
77
- * const fn = Export('function', 'calculateTotal', 'Calculate order total', {
78
- * parameters: {
79
- * items: ['Array of order items'],
80
- * taxRate: 'Tax rate (number)',
81
- * },
82
- * returns: 'Total amount (number)',
83
- * })
84
- *
85
- * const cls = Export('class', 'OrderManager', 'Manage orders', {
86
- * methods: [
87
- * Export('function', 'create', 'Create order', {
88
- * parameters: { order: 'Order data' },
89
- * returns: 'Created order',
90
- * }),
91
- * ],
92
- * })
93
- * ```
94
- */
95
- export function Export(type, name, description, options) {
96
- return {
97
- type,
98
- name,
99
- description,
100
- parameters: options?.parameters,
101
- returns: options?.returns,
102
- methods: options?.methods,
103
- };
104
- }
105
- /**
106
- * Helper to create an SDK example
107
- *
108
- * @example
109
- * ```ts
110
- * const example = Example(
111
- * 'Authentication',
112
- * 'How to authenticate with the API',
113
- * `const client = createClient({
114
- * apiKey: process.env.API_KEY,
115
- * })`,
116
- * '{ authenticated: true }'
117
- * )
118
- * ```
119
- */
120
- export function Example(title, description, code, output) {
121
- return {
122
- title,
123
- description,
124
- code,
125
- output,
126
- };
127
- }
package/src/site.js DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * Site() - Define a website
3
- */
4
- import { registerProduct } from './product.js';
5
- /**
6
- * Create a site definition
7
- *
8
- * @example
9
- * ```ts
10
- * const docsSite = Site({
11
- * id: 'docs',
12
- * name: 'Documentation Site',
13
- * description: 'Product documentation',
14
- * version: '1.0.0',
15
- * generator: 'fumadocs',
16
- * structure: {
17
- * home: '/docs/index.mdx',
18
- * docs: [
19
- * '/docs/getting-started.mdx',
20
- * '/docs/api-reference.mdx',
21
- * ],
22
- * },
23
- * navigation: [
24
- * Nav('Home', '/'),
25
- * Nav('Docs', '/docs', {
26
- * children: [
27
- * Nav('Getting Started', '/docs/getting-started'),
28
- * Nav('API Reference', '/docs/api-reference'),
29
- * ],
30
- * }),
31
- * ],
32
- * seo: {
33
- * titleTemplate: '%s | My Product',
34
- * description: 'Official documentation for My Product',
35
- * keywords: ['docs', 'api', 'reference'],
36
- * },
37
- * analytics: {
38
- * provider: 'plausible',
39
- * id: 'docs.example.com',
40
- * },
41
- * })
42
- * ```
43
- */
44
- export function Site(config) {
45
- const site = {
46
- type: 'site',
47
- id: config.id,
48
- name: config.name,
49
- description: config.description,
50
- version: config.version,
51
- generator: config.generator || 'next',
52
- structure: config.structure,
53
- navigation: config.navigation,
54
- seo: config.seo,
55
- analytics: config.analytics,
56
- deployment: config.deployment,
57
- metadata: config.metadata,
58
- tags: config.tags,
59
- status: config.status || 'active',
60
- };
61
- return registerProduct(site);
62
- }
63
- /**
64
- * Helper to create a navigation item
65
- *
66
- * @example
67
- * ```ts
68
- * const nav = Nav('Documentation', '/docs', {
69
- * icon: 'book',
70
- * children: [
71
- * Nav('Getting Started', '/docs/getting-started'),
72
- * Nav('API Reference', '/docs/api'),
73
- * ],
74
- * })
75
- * ```
76
- */
77
- export function Nav(label, href, options) {
78
- return {
79
- label,
80
- href,
81
- ...options,
82
- };
83
- }
84
- /**
85
- * Helper to configure SEO
86
- *
87
- * @example
88
- * ```ts
89
- * const seo = SEO({
90
- * titleTemplate: '%s | My Site',
91
- * description: 'My awesome site',
92
- * keywords: ['keyword1', 'keyword2'],
93
- * ogImage: '/og-image.png',
94
- * twitterCard: 'summary_large_image',
95
- * })
96
- * ```
97
- */
98
- export function SEO(config) {
99
- return config;
100
- }
101
- /**
102
- * Helper to configure analytics
103
- *
104
- * @example
105
- * ```ts
106
- * const analytics = Analytics('google', 'G-XXXXXXXXXX')
107
- * const analytics = Analytics('plausible', 'example.com')
108
- * ```
109
- */
110
- export function Analytics(provider, id, config) {
111
- return { provider, id, config };
112
- }
package/src/types.js DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Core types for digital products
3
- */
4
- export {};