@openfn/language-common 1.7.6 → 1.7.7

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.
@@ -0,0 +1,59 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/metadata.js
20
+ var metadata_exports = {};
21
+ __export(metadata_exports, {
22
+ createEntity: () => createEntity
23
+ });
24
+ module.exports = __toCommonJS(metadata_exports);
25
+ var createEntity = (name, type, props = {}, children) => {
26
+ const { label, datatype, value, ...meta } = props;
27
+ const e = {
28
+ name,
29
+ type,
30
+ addChild: function(e2, name2) {
31
+ if (!this.children) {
32
+ this.children = name2 ? {} : [];
33
+ }
34
+ if (name2) {
35
+ if (isArray(this.children)) {
36
+ throw new Error("Cannot add a named entity to child array");
37
+ }
38
+ this.children[name2] = e2;
39
+ } else {
40
+ this.children.push(e2);
41
+ }
42
+ }
43
+ };
44
+ if (label) {
45
+ e.label = label;
46
+ }
47
+ if (datatype) {
48
+ e.datatype = datatype;
49
+ }
50
+ if (children) {
51
+ e.children = children;
52
+ }
53
+ e.meta = meta || {};
54
+ return e;
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ createEntity
59
+ });
@@ -0,0 +1,35 @@
1
+ // src/metadata.js
2
+ var createEntity = (name, type, props = {}, children) => {
3
+ const { label, datatype, value, ...meta } = props;
4
+ const e = {
5
+ name,
6
+ type,
7
+ addChild: function(e2, name2) {
8
+ if (!this.children) {
9
+ this.children = name2 ? {} : [];
10
+ }
11
+ if (name2) {
12
+ if (isArray(this.children)) {
13
+ throw new Error("Cannot add a named entity to child array");
14
+ }
15
+ this.children[name2] = e2;
16
+ } else {
17
+ this.children.push(e2);
18
+ }
19
+ }
20
+ };
21
+ if (label) {
22
+ e.label = label;
23
+ }
24
+ if (datatype) {
25
+ e.datatype = datatype;
26
+ }
27
+ if (children) {
28
+ e.children = children;
29
+ }
30
+ e.meta = meta || {};
31
+ return e;
32
+ };
33
+ export {
34
+ createEntity
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-common",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "Common Expressions for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -12,7 +12,11 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
- "./package.json": "./package.json"
15
+ "./package.json": "./package.json",
16
+ "./metadata": {
17
+ "import": "./dist/metadata.js",
18
+ "require": "./dist/metadata.cjs"
19
+ }
16
20
  },
17
21
  "author": "Open Function Group",
18
22
  "license": "LGPL-3.0-or-later",
package/types/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as Adaptor from './Adaptor';
1
2
  export default Adaptor;
2
- export * from "./Adaptor";
3
- import * as Adaptor from "./Adaptor";
3
+ export * from './Adaptor';
4
+ import * as metadata from './metadata';
5
+ export { metadata };
@@ -0,0 +1,11 @@
1
+ declare type Entity = {
2
+ name: string;
3
+ type: string;
4
+ label?: string;
5
+ datatype?: string;
6
+ desc?: string;
7
+ children?: Entity[] | Record<string, Entity>;
8
+ meta?: Record<string, any>;
9
+ addChild: (e: Entity, name?: string) => void;
10
+ };
11
+ declare type DataType = 'string' | 'boolean' | 'date';