@elaraai/e3-types 0.0.1-beta.0 → 0.0.2-beta.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.
package/README.md CHANGED
@@ -18,16 +18,45 @@ npm install @elaraai/e3-types
18
18
  - **Dataflow** - Dataflow definitions
19
19
  - **Runner** - Runner configuration
20
20
 
21
- ## Related Repos
22
21
 
23
- - **[east](https://github.com/elaraai/east)** - East language core
24
- - **[east-node](https://github.com/elaraai/east-node)** - Node.js runtime and platform functions
25
- - **[east-py](https://github.com/elaraai/east-py)** - Python runtime and data science
22
+ ## License
23
+
24
+ Dual AGPL-3.0 / Commercial. See [LICENSE.md](./LICENSE.md).
25
+
26
+ ### Ecosystem
27
+
28
+ - **[East Node](https://github.com/elaraai/east-node)**: Node.js platform functions for I/O, databases, and system operations. Connect East programs to filesystems, SQL/NoSQL databases, cloud storage, and network services.
29
+ - [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Filesystem, console, HTTP fetch, crypto, random distributions, timestamps
30
+ - [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, S3, FTP, SFTP
31
+ - [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
32
+
33
+ - **[East Python](https://github.com/elaraai/east-py)**: Python runtime and platform functions for data science and machine learning. Execute East programs with access to optimization solvers, gradient boosting, neural networks, and model explainability.
34
+ - [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience): TypeScript types for optimization, gradient boosting, neural networks, explainability
35
+
36
+ - **[East UI](https://github.com/elaraai/east-ui)**: East types and expressions for building dashboards and interactive layouts. Define UIs as data structures that render consistently across React, web, and other environments.
37
+ - [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
38
+ - [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI styling
39
+
40
+ - **[e3 - East Execution Engine](https://github.com/elaraai/e3)**: Durable execution engine for running East pipelines at scale. Features Git-like content-addressable storage, automatic memoization, task queuing, and real-time monitoring.
41
+ - [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
42
+ - [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
43
+ - [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
44
+ - [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 init`, `e3 run`, `e3 logs` commands for managing and monitoring tasks
45
+ - [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
46
+ - [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
47
+
48
+ ## Links
49
+
50
+ - [East Language](https://github.com/elaraai/east)
51
+ - [East Python Runtime](https://github.com/elaraai/east-py)
52
+ - [Elara AI](https://elaraai.com/)
53
+ - [Issues](https://github.com/elaraai/e3/issues)
54
+ - support@elara.ai
26
55
 
27
56
  ## About Elara
28
57
 
29
- e3 is developed by [Elara AI](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses. e3 powers the execution layer of Elara solutions, enabling durable and efficient execution of East programs across multiple runtimes.
58
+ East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.
30
59
 
31
- ## License
60
+ ---
32
61
 
33
- Dual AGPL-3.0 / Commercial. See [LICENSE.md](./LICENSE.md).
62
+ *Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
@@ -22,7 +22,7 @@
22
22
  */
23
23
  export { DataRefType, type DataRef, unassignedRef, nullRef, DataTreeType, } from './dataset.js';
24
24
  export { TaskObjectType, type TaskObject, } from './task.js';
25
- export { StructureType, type Structure, PathSegmentType, type PathSegment, TreePathType, type TreePath, type ParsePathResult, treePath, pathToString, parsePath, DatasetSchemaType, type DatasetSchema, } from './structure.js';
25
+ export { StructureType, type Structure, PathSegmentType, type PathSegment, TreePathType, type TreePath, type ParsePathResult, type ParseDatasetPathResult, type ParsePackageRefResult, treePath, pathToString, parsePath, parseDatasetPath, parsePackageRef, urlPathToTreePath, DatasetSchemaType, type DatasetSchema, } from './structure.js';
26
26
  export { PackageDataType, type PackageData, PackageObjectType, type PackageObject, PackageDatasetsType, type PackageDatasets, } from './package.js';
27
27
  export { WorkspaceStateType, type WorkspaceState, } from './workspace.js';
28
28
  export { ExecutionStatusType, type ExecutionStatus, } from './execution.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,aAAa,EACb,KAAK,SAAS,EACd,eAAe,EACf,KAAK,WAAW,EAChB,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,QAAQ,EACR,YAAY,EACZ,SAAS,EAET,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,KAAK,WAAW,EAChB,iBAAiB,EACjB,KAAK,aAAa,EAElB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,aAAa,EACb,KAAK,SAAS,EACd,eAAe,EACf,KAAK,WAAW,EAChB,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAEjB,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,KAAK,WAAW,EAChB,iBAAiB,EACjB,KAAK,aAAa,EAElB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC"}
package/dist/src/index.js CHANGED
@@ -25,7 +25,7 @@ export { DataRefType, unassignedRef, nullRef, DataTreeType, } from './dataset.js
25
25
  // Task definitions
26
26
  export { TaskObjectType, } from './task.js';
27
27
  // Data structure and paths
28
- export { StructureType, PathSegmentType, TreePathType, treePath, pathToString, parsePath,
28
+ export { StructureType, PathSegmentType, TreePathType, treePath, pathToString, parsePath, parseDatasetPath, parsePackageRef, urlPathToTreePath,
29
29
  // Backwards compatibility
30
30
  DatasetSchemaType, } from './structure.js';
31
31
  // Package objects
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,4BAA4B;AAC5B,OAAO,EACL,WAAW,EAEX,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,mBAAmB;AACnB,OAAO,EACL,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,2BAA2B;AAC3B,OAAO,EACL,aAAa,EAEb,eAAe,EAEf,YAAY,EAGZ,QAAQ,EACR,YAAY,EACZ,SAAS;AACT,0BAA0B;AAC1B,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AAExB,kBAAkB;AAClB,OAAO,EACL,eAAe,EAEf,iBAAiB;AAEjB,0BAA0B;AAC1B,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AAEtB,kBAAkB;AAClB,OAAO,EACL,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AAExB,mBAAmB;AACnB,OAAO,EACL,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,4BAA4B;AAC5B,OAAO,EACL,WAAW,EAEX,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,mBAAmB;AACnB,OAAO,EACL,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,2BAA2B;AAC3B,OAAO,EACL,aAAa,EAEb,eAAe,EAEf,YAAY,EAKZ,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,iBAAiB;AACjB,0BAA0B;AAC1B,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AAExB,kBAAkB;AAClB,OAAO,EACL,eAAe,EAEf,iBAAiB;AAEjB,0BAA0B;AAC1B,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AAEtB,kBAAkB;AAClB,OAAO,EACL,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AAExB,mBAAmB;AACnB,OAAO,EACL,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC"}
@@ -251,4 +251,89 @@ export declare function parsePath(pathStr: string, structure: Structure): ParseP
251
251
  * ```
252
252
  */
253
253
  export declare function treePath(structure: Structure, ...fields: string[]): ParsePathResult;
254
+ /**
255
+ * Result of parsing a dataset path specification.
256
+ */
257
+ export interface ParseDatasetPathResult {
258
+ /** Workspace name */
259
+ ws: string;
260
+ /** Path within the workspace */
261
+ path: TreePath;
262
+ }
263
+ /**
264
+ * Parse workspace.path.to.dataset syntax into workspace name and TreePath.
265
+ *
266
+ * This is a lenient parser that does not validate against a structure.
267
+ * Use this for parsing user input where the structure is not yet known.
268
+ *
269
+ * @param pathSpec - Path specification in dot notation (e.g., "production.inputs.sales")
270
+ * @returns Workspace name and path segments
271
+ *
272
+ * @throws {Error} If path is empty or has unclosed backticks
273
+ *
274
+ * @example
275
+ * ```ts
276
+ * parseDatasetPath("production")
277
+ * // { ws: "production", path: [] }
278
+ *
279
+ * parseDatasetPath("production.inputs.sales")
280
+ * // { ws: "production", path: [field("inputs"), field("sales")] }
281
+ *
282
+ * // For field names with special characters, use backticks:
283
+ * parseDatasetPath("production.`my field`")
284
+ * // { ws: "production", path: [field("my field")] }
285
+ * ```
286
+ */
287
+ export declare function parseDatasetPath(pathSpec: string): ParseDatasetPathResult;
288
+ /**
289
+ * Result of parsing a package reference.
290
+ */
291
+ export interface ParsePackageRefResult {
292
+ /** Package name */
293
+ name: string;
294
+ /** Version string, or undefined if not specified */
295
+ version?: string;
296
+ }
297
+ /**
298
+ * Parse a package reference like "name" or "name@version".
299
+ *
300
+ * @param ref - Package reference string
301
+ * @returns Package name and optional version
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * parsePackageRef("my-package")
306
+ * // { name: "my-package", version: undefined }
307
+ *
308
+ * parsePackageRef("my-package@1.0.0")
309
+ * // { name: "my-package", version: "1.0.0" }
310
+ *
311
+ * // Scoped packages work too:
312
+ * parsePackageRef("@scope/package@2.0.0")
313
+ * // { name: "@scope/package", version: "2.0.0" }
314
+ * ```
315
+ */
316
+ export declare function parsePackageRef(ref: string): ParsePackageRefResult;
317
+ /**
318
+ * Convert URL path segments to a TreePath.
319
+ *
320
+ * Takes slash-separated, URL-encoded path segments and converts them to
321
+ * a TreePath of field variants.
322
+ *
323
+ * @param urlPath - URL path string (e.g., "inputs/sales/data" or "/inputs/sales/data")
324
+ * @returns TreePath of field segments
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * urlPathToTreePath("inputs/sales/data")
329
+ * // [field("inputs"), field("sales"), field("data")]
330
+ *
331
+ * urlPathToTreePath("inputs/my%20field")
332
+ * // [field("inputs"), field("my field")]
333
+ *
334
+ * urlPathToTreePath("")
335
+ * // []
336
+ * ```
337
+ */
338
+ export declare function urlPathToTreePath(urlPath: string): TreePath;
254
339
  //# sourceMappingURL=structure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAA0C,MAAM,eAAe,CAAC;AAEjJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,aAAa;IACxB,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEjE,8DAA8D;;GAE7D,CAAC;AACJ,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAG1D,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB;IAX5B,iEAAiE;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;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,eAAe,CAgEhF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAEnF;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAWzE;AAqCD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAUlE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAG3D"}
@@ -233,4 +233,123 @@ export function parsePath(pathStr, structure) {
233
233
  export function treePath(structure, ...fields) {
234
234
  return parsePath('.' + fields.map(printIdentifier).join('.'), structure);
235
235
  }
236
+ /**
237
+ * Parse workspace.path.to.dataset syntax into workspace name and TreePath.
238
+ *
239
+ * This is a lenient parser that does not validate against a structure.
240
+ * Use this for parsing user input where the structure is not yet known.
241
+ *
242
+ * @param pathSpec - Path specification in dot notation (e.g., "production.inputs.sales")
243
+ * @returns Workspace name and path segments
244
+ *
245
+ * @throws {Error} If path is empty or has unclosed backticks
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * parseDatasetPath("production")
250
+ * // { ws: "production", path: [] }
251
+ *
252
+ * parseDatasetPath("production.inputs.sales")
253
+ * // { ws: "production", path: [field("inputs"), field("sales")] }
254
+ *
255
+ * // For field names with special characters, use backticks:
256
+ * parseDatasetPath("production.`my field`")
257
+ * // { ws: "production", path: [field("my field")] }
258
+ * ```
259
+ */
260
+ export function parseDatasetPath(pathSpec) {
261
+ const segments = parsePathSegments(pathSpec);
262
+ if (segments.length === 0) {
263
+ throw new Error('Path cannot be empty');
264
+ }
265
+ const ws = segments[0];
266
+ const path = segments.slice(1).map((s) => variant('field', s));
267
+ return { ws, path };
268
+ }
269
+ /**
270
+ * Parse dot-separated path into segments, handling backtick-quoted identifiers.
271
+ * @internal
272
+ */
273
+ function parsePathSegments(pathSpec) {
274
+ const segments = [];
275
+ let current = '';
276
+ let inBackticks = false;
277
+ for (let i = 0; i < pathSpec.length; i++) {
278
+ const char = pathSpec[i];
279
+ if (char === '`') {
280
+ inBackticks = !inBackticks;
281
+ }
282
+ else if (char === '.' && !inBackticks) {
283
+ if (current.length > 0) {
284
+ segments.push(current);
285
+ current = '';
286
+ }
287
+ }
288
+ else {
289
+ current += char;
290
+ }
291
+ }
292
+ if (current.length > 0) {
293
+ segments.push(current);
294
+ }
295
+ if (inBackticks) {
296
+ throw new Error('Unclosed backtick in path');
297
+ }
298
+ return segments;
299
+ }
300
+ /**
301
+ * Parse a package reference like "name" or "name@version".
302
+ *
303
+ * @param ref - Package reference string
304
+ * @returns Package name and optional version
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * parsePackageRef("my-package")
309
+ * // { name: "my-package", version: undefined }
310
+ *
311
+ * parsePackageRef("my-package@1.0.0")
312
+ * // { name: "my-package", version: "1.0.0" }
313
+ *
314
+ * // Scoped packages work too:
315
+ * parsePackageRef("@scope/package@2.0.0")
316
+ * // { name: "@scope/package", version: "2.0.0" }
317
+ * ```
318
+ */
319
+ export function parsePackageRef(ref) {
320
+ const atIdx = ref.lastIndexOf('@');
321
+ // Handle scoped packages like @scope/name - only split on @ after position 0
322
+ if (atIdx > 0) {
323
+ return {
324
+ name: ref.slice(0, atIdx),
325
+ version: ref.slice(atIdx + 1),
326
+ };
327
+ }
328
+ return { name: ref };
329
+ }
330
+ /**
331
+ * Convert URL path segments to a TreePath.
332
+ *
333
+ * Takes slash-separated, URL-encoded path segments and converts them to
334
+ * a TreePath of field variants.
335
+ *
336
+ * @param urlPath - URL path string (e.g., "inputs/sales/data" or "/inputs/sales/data")
337
+ * @returns TreePath of field segments
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * urlPathToTreePath("inputs/sales/data")
342
+ * // [field("inputs"), field("sales"), field("data")]
343
+ *
344
+ * urlPathToTreePath("inputs/my%20field")
345
+ * // [field("inputs"), field("my field")]
346
+ *
347
+ * urlPathToTreePath("")
348
+ * // []
349
+ * ```
350
+ */
351
+ export function urlPathToTreePath(urlPath) {
352
+ const segments = urlPath.split('/').filter(p => p);
353
+ return segments.map(segment => variant('field', decodeURIComponent(segment)));
354
+ }
236
355
  //# sourceMappingURL=structure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"structure.js","sourceRoot":"","sources":["../../src/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAe,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEjJ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC;IAC7D,iEAAiE;IACjE,KAAK,EAAE,YAAY;IACnB,8DAA8D;IAC9D,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;CACnC,CAAC,CAAC,CAAC;AAKJ,gCAAgC;AAChC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC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,CAAC;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elaraai/e3-types",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.2-beta.1",
4
4
  "description": "Shared type definitions for e3 (East Execution Engine)",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -18,8 +18,13 @@
18
18
  ],
19
19
  "author": "Elara AI",
20
20
  "license": "SEE LICENSE IN LICENSE",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/elaraai/e3",
24
+ "directory": "packages/e3-types"
25
+ },
21
26
  "dependencies": {
22
- "@elaraai/east": "0.0.1-beta.11"
27
+ "@elaraai/east": "^0.0.1-beta.14"
23
28
  },
24
29
  "devDependencies": {
25
30
  "@typescript-eslint/eslint-plugin": "^8.47.0",
package/src/index.ts CHANGED
@@ -46,9 +46,14 @@ export {
46
46
  TreePathType,
47
47
  type TreePath,
48
48
  type ParsePathResult,
49
+ type ParseDatasetPathResult,
50
+ type ParsePackageRefResult,
49
51
  treePath,
50
52
  pathToString,
51
53
  parsePath,
54
+ parseDatasetPath,
55
+ parsePackageRef,
56
+ urlPathToTreePath,
52
57
  // Backwards compatibility
53
58
  DatasetSchemaType,
54
59
  type DatasetSchema,
package/src/structure.ts CHANGED
@@ -268,3 +268,152 @@ export function parsePath(pathStr: string, structure: Structure): ParsePathResul
268
268
  export function treePath(structure: Structure, ...fields: string[]): ParsePathResult {
269
269
  return parsePath('.' + fields.map(printIdentifier).join('.'), structure);
270
270
  }
271
+
272
+ /**
273
+ * Result of parsing a dataset path specification.
274
+ */
275
+ export interface ParseDatasetPathResult {
276
+ /** Workspace name */
277
+ ws: string;
278
+ /** Path within the workspace */
279
+ path: TreePath;
280
+ }
281
+
282
+ /**
283
+ * Parse workspace.path.to.dataset syntax into workspace name and TreePath.
284
+ *
285
+ * This is a lenient parser that does not validate against a structure.
286
+ * Use this for parsing user input where the structure is not yet known.
287
+ *
288
+ * @param pathSpec - Path specification in dot notation (e.g., "production.inputs.sales")
289
+ * @returns Workspace name and path segments
290
+ *
291
+ * @throws {Error} If path is empty or has unclosed backticks
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * parseDatasetPath("production")
296
+ * // { ws: "production", path: [] }
297
+ *
298
+ * parseDatasetPath("production.inputs.sales")
299
+ * // { ws: "production", path: [field("inputs"), field("sales")] }
300
+ *
301
+ * // For field names with special characters, use backticks:
302
+ * parseDatasetPath("production.`my field`")
303
+ * // { ws: "production", path: [field("my field")] }
304
+ * ```
305
+ */
306
+ export function parseDatasetPath(pathSpec: string): ParseDatasetPathResult {
307
+ const segments = parsePathSegments(pathSpec);
308
+
309
+ if (segments.length === 0) {
310
+ throw new Error('Path cannot be empty');
311
+ }
312
+
313
+ const ws = segments[0]!;
314
+ const path: TreePath = segments.slice(1).map((s) => variant('field', s));
315
+
316
+ return { ws, path };
317
+ }
318
+
319
+ /**
320
+ * Parse dot-separated path into segments, handling backtick-quoted identifiers.
321
+ * @internal
322
+ */
323
+ function parsePathSegments(pathSpec: string): string[] {
324
+ const segments: string[] = [];
325
+ let current = '';
326
+ let inBackticks = false;
327
+
328
+ for (let i = 0; i < pathSpec.length; i++) {
329
+ const char = pathSpec[i];
330
+
331
+ if (char === '`') {
332
+ inBackticks = !inBackticks;
333
+ } else if (char === '.' && !inBackticks) {
334
+ if (current.length > 0) {
335
+ segments.push(current);
336
+ current = '';
337
+ }
338
+ } else {
339
+ current += char;
340
+ }
341
+ }
342
+
343
+ if (current.length > 0) {
344
+ segments.push(current);
345
+ }
346
+
347
+ if (inBackticks) {
348
+ throw new Error('Unclosed backtick in path');
349
+ }
350
+
351
+ return segments;
352
+ }
353
+
354
+ /**
355
+ * Result of parsing a package reference.
356
+ */
357
+ export interface ParsePackageRefResult {
358
+ /** Package name */
359
+ name: string;
360
+ /** Version string, or undefined if not specified */
361
+ version?: string;
362
+ }
363
+
364
+ /**
365
+ * Parse a package reference like "name" or "name@version".
366
+ *
367
+ * @param ref - Package reference string
368
+ * @returns Package name and optional version
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * parsePackageRef("my-package")
373
+ * // { name: "my-package", version: undefined }
374
+ *
375
+ * parsePackageRef("my-package@1.0.0")
376
+ * // { name: "my-package", version: "1.0.0" }
377
+ *
378
+ * // Scoped packages work too:
379
+ * parsePackageRef("@scope/package@2.0.0")
380
+ * // { name: "@scope/package", version: "2.0.0" }
381
+ * ```
382
+ */
383
+ export function parsePackageRef(ref: string): ParsePackageRefResult {
384
+ const atIdx = ref.lastIndexOf('@');
385
+ // Handle scoped packages like @scope/name - only split on @ after position 0
386
+ if (atIdx > 0) {
387
+ return {
388
+ name: ref.slice(0, atIdx),
389
+ version: ref.slice(atIdx + 1),
390
+ };
391
+ }
392
+ return { name: ref };
393
+ }
394
+
395
+ /**
396
+ * Convert URL path segments to a TreePath.
397
+ *
398
+ * Takes slash-separated, URL-encoded path segments and converts them to
399
+ * a TreePath of field variants.
400
+ *
401
+ * @param urlPath - URL path string (e.g., "inputs/sales/data" or "/inputs/sales/data")
402
+ * @returns TreePath of field segments
403
+ *
404
+ * @example
405
+ * ```ts
406
+ * urlPathToTreePath("inputs/sales/data")
407
+ * // [field("inputs"), field("sales"), field("data")]
408
+ *
409
+ * urlPathToTreePath("inputs/my%20field")
410
+ * // [field("inputs"), field("my field")]
411
+ *
412
+ * urlPathToTreePath("")
413
+ * // []
414
+ * ```
415
+ */
416
+ export function urlPathToTreePath(urlPath: string): TreePath {
417
+ const segments = urlPath.split('/').filter(p => p);
418
+ return segments.map(segment => variant('field', decodeURIComponent(segment)));
419
+ }