digital-products 2.0.1

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 (110) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +535 -0
  4. package/dist/api.d.ts +99 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +129 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/app.d.ts +79 -0
  9. package/dist/app.d.ts.map +1 -0
  10. package/dist/app.js +107 -0
  11. package/dist/app.js.map +1 -0
  12. package/dist/content.d.ts +58 -0
  13. package/dist/content.d.ts.map +1 -0
  14. package/dist/content.js +78 -0
  15. package/dist/content.js.map +1 -0
  16. package/dist/data.d.ts +67 -0
  17. package/dist/data.d.ts.map +1 -0
  18. package/dist/data.js +107 -0
  19. package/dist/data.js.map +1 -0
  20. package/dist/dataset.d.ts +32 -0
  21. package/dist/dataset.d.ts.map +1 -0
  22. package/dist/dataset.js +50 -0
  23. package/dist/dataset.js.map +1 -0
  24. package/dist/entities/ai.d.ts +53 -0
  25. package/dist/entities/ai.d.ts.map +1 -0
  26. package/dist/entities/ai.js +859 -0
  27. package/dist/entities/ai.js.map +1 -0
  28. package/dist/entities/content.d.ts +52 -0
  29. package/dist/entities/content.d.ts.map +1 -0
  30. package/dist/entities/content.js +784 -0
  31. package/dist/entities/content.js.map +1 -0
  32. package/dist/entities/index.d.ts +112 -0
  33. package/dist/entities/index.d.ts.map +1 -0
  34. package/dist/entities/index.js +89 -0
  35. package/dist/entities/index.js.map +1 -0
  36. package/dist/entities/interfaces.d.ts +67 -0
  37. package/dist/entities/interfaces.d.ts.map +1 -0
  38. package/dist/entities/interfaces.js +930 -0
  39. package/dist/entities/interfaces.js.map +1 -0
  40. package/dist/entities/lifecycle.d.ts +51 -0
  41. package/dist/entities/lifecycle.d.ts.map +1 -0
  42. package/dist/entities/lifecycle.js +804 -0
  43. package/dist/entities/lifecycle.js.map +1 -0
  44. package/dist/entities/products.d.ts +53 -0
  45. package/dist/entities/products.d.ts.map +1 -0
  46. package/dist/entities/products.js +798 -0
  47. package/dist/entities/products.js.map +1 -0
  48. package/dist/entities/web.d.ts +44 -0
  49. package/dist/entities/web.d.ts.map +1 -0
  50. package/dist/entities/web.js +658 -0
  51. package/dist/entities/web.js.map +1 -0
  52. package/dist/index.d.ts +29 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +36 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/mcp.d.ts +101 -0
  57. package/dist/mcp.d.ts.map +1 -0
  58. package/dist/mcp.js +140 -0
  59. package/dist/mcp.js.map +1 -0
  60. package/dist/product.d.ts +37 -0
  61. package/dist/product.d.ts.map +1 -0
  62. package/dist/product.js +54 -0
  63. package/dist/product.js.map +1 -0
  64. package/dist/registry.d.ts +9 -0
  65. package/dist/registry.d.ts.map +1 -0
  66. package/dist/registry.js +32 -0
  67. package/dist/registry.js.map +1 -0
  68. package/dist/sdk.d.ts +99 -0
  69. package/dist/sdk.d.ts.map +1 -0
  70. package/dist/sdk.js +128 -0
  71. package/dist/sdk.js.map +1 -0
  72. package/dist/site.d.ts +85 -0
  73. package/dist/site.d.ts.map +1 -0
  74. package/dist/site.js +113 -0
  75. package/dist/site.js.map +1 -0
  76. package/dist/types.d.ts +528 -0
  77. package/dist/types.d.ts.map +1 -0
  78. package/dist/types.js +5 -0
  79. package/dist/types.js.map +1 -0
  80. package/example.ts +236 -0
  81. package/package.json +35 -0
  82. package/src/api.ts +140 -0
  83. package/src/app.ts +117 -0
  84. package/src/content.ts +82 -0
  85. package/src/data.ts +129 -0
  86. package/src/dataset.ts +53 -0
  87. package/src/entities/ai.ts +932 -0
  88. package/src/entities/content.ts +851 -0
  89. package/src/entities/index.ts +156 -0
  90. package/src/entities/interfaces.ts +1017 -0
  91. package/src/entities/lifecycle.ts +872 -0
  92. package/src/entities/products.ts +867 -0
  93. package/src/entities/web.ts +719 -0
  94. package/src/index.ts +55 -0
  95. package/src/mcp.ts +163 -0
  96. package/src/product.ts +59 -0
  97. package/src/registry.ts +41 -0
  98. package/src/sdk.ts +148 -0
  99. package/src/site.ts +127 -0
  100. package/src/types.ts +558 -0
  101. package/test/api.test.ts +247 -0
  102. package/test/app.test.ts +220 -0
  103. package/test/content.test.ts +171 -0
  104. package/test/data.test.ts +201 -0
  105. package/test/dataset.test.ts +181 -0
  106. package/test/mcp.test.ts +230 -0
  107. package/test/product.test.ts +200 -0
  108. package/test/sdk.test.ts +236 -0
  109. package/test/site.test.ts +245 -0
  110. package/tsconfig.json +9 -0
package/dist/api.js ADDED
@@ -0,0 +1,129 @@
1
+ /**
2
+ * API() - Define an API
3
+ */
4
+ import { registerProduct } from './product.js';
5
+ /**
6
+ * Create an API definition
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const myAPI = API({
11
+ * id: 'my-api',
12
+ * name: 'My API',
13
+ * description: 'A RESTful API',
14
+ * version: '1.0.0',
15
+ * style: 'rest',
16
+ * baseUrl: 'https://api.example.com',
17
+ * endpoints: [
18
+ * Endpoint('GET', '/users', 'List all users', {
19
+ * response: {
20
+ * users: ['Array of user objects'],
21
+ * total: 'Total count (number)',
22
+ * },
23
+ * }),
24
+ * Endpoint('POST', '/users', 'Create a user', {
25
+ * request: {
26
+ * name: 'User name',
27
+ * email: 'User email',
28
+ * },
29
+ * response: {
30
+ * id: 'User ID',
31
+ * name: 'User name',
32
+ * email: 'User email',
33
+ * },
34
+ * }),
35
+ * ],
36
+ * auth: {
37
+ * type: 'bearer',
38
+ * header: 'Authorization',
39
+ * },
40
+ * rateLimit: {
41
+ * requests: 100,
42
+ * window: 60,
43
+ * },
44
+ * })
45
+ * ```
46
+ */
47
+ export function API(config) {
48
+ const api = {
49
+ type: 'api',
50
+ id: config.id,
51
+ name: config.name,
52
+ description: config.description,
53
+ version: config.version,
54
+ style: config.style || 'rest',
55
+ baseUrl: config.baseUrl,
56
+ endpoints: config.endpoints || [],
57
+ auth: config.auth,
58
+ rateLimit: config.rateLimit,
59
+ docsUrl: config.docsUrl,
60
+ openapi: config.openapi,
61
+ metadata: config.metadata,
62
+ tags: config.tags,
63
+ status: config.status || 'active',
64
+ };
65
+ return registerProduct(api);
66
+ }
67
+ /**
68
+ * Helper to create an endpoint definition
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const endpoint = Endpoint('GET', '/users/:id', 'Get user by ID', {
73
+ * params: { id: 'User ID' },
74
+ * response: {
75
+ * id: 'User ID',
76
+ * name: 'User name',
77
+ * email: 'User email',
78
+ * },
79
+ * auth: true,
80
+ * })
81
+ * ```
82
+ */
83
+ export function Endpoint(method, path, description, options) {
84
+ return {
85
+ method,
86
+ path,
87
+ description,
88
+ ...options,
89
+ };
90
+ }
91
+ /**
92
+ * Helper to configure API authentication
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const auth = APIAuth({
97
+ * type: 'bearer',
98
+ * header: 'Authorization',
99
+ * })
100
+ *
101
+ * const oauth = APIAuth({
102
+ * type: 'oauth2',
103
+ * oauth2: {
104
+ * authUrl: 'https://auth.example.com/authorize',
105
+ * tokenUrl: 'https://auth.example.com/token',
106
+ * scopes: ['read', 'write'],
107
+ * },
108
+ * })
109
+ * ```
110
+ */
111
+ export function APIAuth(config) {
112
+ return config;
113
+ }
114
+ /**
115
+ * Helper to configure rate limiting
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const rateLimit = RateLimit({
120
+ * requests: 100,
121
+ * window: 60, // 60 seconds
122
+ * onExceeded: 'reject',
123
+ * })
124
+ * ```
125
+ */
126
+ export function RateLimit(config) {
127
+ return config;
128
+ }
129
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,GAAG,CAAC,MAAmC;IACrD,MAAM,GAAG,GAAkB;QACzB,IAAI,EAAE,KAAK;QACX,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;QACjC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;KAClC,CAAA;IAED,OAAO,eAAe,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAoC,EACpC,IAAY,EACZ,WAAmB,EACnB,OAAqE;IAErE,OAAO;QACL,MAAM;QACN,IAAI;QACJ,WAAW;QACX,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,MAAqB;IAC3C,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB;IAC/C,OAAO,MAAM,CAAA;AACf,CAAC"}
package/dist/app.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * App() - Define an application
3
+ */
4
+ import type { AppDefinition, RouteDefinition, StateDefinition, AuthConfig } from './types.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 declare function App(config: Omit<AppDefinition, 'type'>): AppDefinition;
36
+ /**
37
+ * Helper to create a route definition
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const userRoute = Route('/users/:id', 'UserDetail', {
42
+ * meta: { title: 'User Profile' },
43
+ * })
44
+ * ```
45
+ */
46
+ export declare function Route(path: string, component: string, options?: Omit<RouteDefinition, 'path' | 'component'>): RouteDefinition;
47
+ /**
48
+ * Helper to configure state management
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const state = State({
53
+ * library: 'zustand',
54
+ * schema: {
55
+ * user: 'Current user',
56
+ * settings: 'User settings',
57
+ * },
58
+ * persistence: {
59
+ * type: 'local',
60
+ * key: 'app-state',
61
+ * },
62
+ * })
63
+ * ```
64
+ */
65
+ export declare function State(config: StateDefinition): StateDefinition;
66
+ /**
67
+ * Helper to configure authentication
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const auth = Auth({
72
+ * provider: 'clerk',
73
+ * protectedRoutes: ['/dashboard', '/profile'],
74
+ * roles: ['admin', 'user'],
75
+ * })
76
+ * ```
77
+ */
78
+ export declare function Auth(config: AuthConfig): AuthConfig;
79
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,aAAa,CAmBtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAAC,GACpD,eAAe,CAMjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAE9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAEnD"}
package/dist/app.js ADDED
@@ -0,0 +1,107 @@
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
+ }
107
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,GAAG,CAAC,MAAmC;IACrD,MAAM,GAAG,GAAkB;QACzB,IAAI,EAAE,KAAK;QACX,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,OAAO;QACtC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;KAClC,CAAA;IAED,OAAO,eAAe,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CACnB,IAAY,EACZ,SAAiB,EACjB,OAAqD;IAErD,OAAO;QACL,IAAI;QACJ,SAAS;QACT,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,KAAK,CAAC,MAAuB;IAC3C,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,IAAI,CAAC,MAAkB;IACrC,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Content() - Define content
3
+ */
4
+ import type { ContentDefinition, WorkflowDefinition } from './types.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 declare function Content(config: Omit<ContentDefinition, 'type'>): ContentDefinition;
37
+ /**
38
+ * Helper to create a workflow definition
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const workflow = Workflow({
43
+ * states: ['draft', 'review', 'published', 'archived'],
44
+ * initialState: 'draft',
45
+ * transitions: [
46
+ * { from: 'draft', to: 'review', action: 'submit' },
47
+ * { from: 'review', to: 'published', action: 'approve' },
48
+ * { from: 'review', to: 'draft', action: 'reject' },
49
+ * { from: 'published', to: 'archived', action: 'archive' },
50
+ * ],
51
+ * approvals: [
52
+ * { state: 'review', roles: ['editor', 'admin'] },
53
+ * ],
54
+ * })
55
+ * ```
56
+ */
57
+ export declare function Workflow(config: WorkflowDefinition): WorkflowDefinition;
58
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAmBlF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAEvE"}
@@ -0,0 +1,78 @@
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
+ }
78
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,OAAO,CAAC,MAAuC;IAC7D,MAAM,OAAO,GAAsB;QACjC,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,UAAU;QACnC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;KAClC,CAAA;IAED,OAAO,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,MAA0B;IACjD,OAAO,MAAM,CAAA;AACf,CAAC"}
package/dist/data.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Data() - Define structured data
3
+ */
4
+ import type { DataDefinition, IndexDefinition, RelationshipDefinition, ValidationRule } from './types.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 declare function Data(config: Omit<DataDefinition, 'type'>): DataDefinition;
35
+ /**
36
+ * Helper to create an index definition
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const emailIndex = Index('email_idx', ['email'], { unique: true })
41
+ * const nameIndex = Index('name_idx', ['firstName', 'lastName'])
42
+ * const vectorIndex = Index('embedding_idx', ['embedding'], { type: 'vector' })
43
+ * ```
44
+ */
45
+ export declare function Index(name: string, fields: string[], options?: Omit<IndexDefinition, 'name' | 'fields'>): IndexDefinition;
46
+ /**
47
+ * Helper to create a relationship definition
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const userPosts = Relationship('one-to-many', 'userId', 'posts', 'author')
52
+ * const postTags = Relationship('many-to-many', 'postId', 'tags', 'posts')
53
+ * ```
54
+ */
55
+ export declare function Relationship(type: RelationshipDefinition['type'], from: string, to: string, field: string): RelationshipDefinition;
56
+ /**
57
+ * Helper to create a validation rule
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const emailRule = Validate('email', 'email', 'Must be a valid email')
62
+ * const ageRule = Validate('age', 'min', { value: 18 }, 'Must be 18 or older')
63
+ * const uniqueRule = Validate('username', 'unique', 'Username already taken')
64
+ * ```
65
+ */
66
+ export declare function Validate(field: string, rule: ValidationRule['rule'], paramsOrMessage?: unknown | string, message?: string): ValidationRule;
67
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG,cAAc,CAkBzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,QAAQ,CAAC,GACjD,eAAe,CAMjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACpC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GACZ,sBAAsB,CAOxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,EAC5B,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,EAClC,OAAO,CAAC,EAAE,MAAM,GACf,cAAc,CAWhB"}
package/dist/data.js ADDED
@@ -0,0 +1,107 @@
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
+ }
107
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,IAAI,CAAC,MAAoC;IACvD,MAAM,IAAI,GAAmB;QAC3B,IAAI,EAAE,MAAM;QACZ,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;KAClC,CAAA;IAED,OAAO,eAAe,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CACnB,IAAY,EACZ,MAAgB,EAChB,OAAkD;IAElD,OAAO;QACL,IAAI;QACJ,MAAM;QACN,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAoC,EACpC,IAAY,EACZ,EAAU,EACV,KAAa;IAEb,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,EAAE;QACF,KAAK;KACN,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAa,EACb,IAA4B,EAC5B,eAAkC,EAClC,OAAgB;IAEhB,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,CAAA;IAClD,CAAC;IAED,OAAO;QACL,KAAK;QACL,IAAI;QACJ,MAAM,EAAE,eAAe;QACvB,OAAO;KACR,CAAA;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Dataset() - Define a dataset
3
+ */
4
+ import type { DatasetDefinition } from './types.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 declare function Dataset(config: Omit<DatasetDefinition, 'type'>): DatasetDefinition;
32
+ //# sourceMappingURL=dataset.d.ts.map