@openfn/language-common 1.7.6 → 1.8.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/dist/index.cjs CHANGED
@@ -147,6 +147,7 @@ function expandRequestReferences(params) {
147
147
  const [toKeep, toExpand] = splitKeys(params || {}, [
148
148
  "agentOptions",
149
149
  "body",
150
+ "json",
150
151
  "data",
151
152
  "form",
152
153
  "formData",
@@ -410,10 +411,10 @@ function scrubEmojis(text, replacementChars) {
410
411
  "It's better to replace than remove.",
411
412
  "See https://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters"
412
413
  );
413
- } else if (!replacementChars)
414
- replacementChars = "\uFFFD";
414
+ }
415
+ const newChars = replacementChars || replacementChars == "" ? replacementChars : "\uFFFD";
415
416
  const emojisPattern = /(\uFE0F|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
416
- return text.replace(emojisPattern, replacementChars);
417
+ return text.replace(emojisPattern, newChars);
417
418
  }
418
419
  function chunk(array, chunkSize) {
419
420
  const output = [];
package/dist/index.js CHANGED
@@ -92,6 +92,7 @@ function expandRequestReferences(params) {
92
92
  const [toKeep, toExpand] = splitKeys(params || {}, [
93
93
  "agentOptions",
94
94
  "body",
95
+ "json",
95
96
  "data",
96
97
  "form",
97
98
  "formData",
@@ -355,10 +356,10 @@ function scrubEmojis(text, replacementChars) {
355
356
  "It's better to replace than remove.",
356
357
  "See https://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters"
357
358
  );
358
- } else if (!replacementChars)
359
- replacementChars = "\uFFFD";
359
+ }
360
+ const newChars = replacementChars || replacementChars == "" ? replacementChars : "\uFFFD";
360
361
  const emojisPattern = /(\uFE0F|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
361
- return text.replace(emojisPattern, replacementChars);
362
+ return text.replace(emojisPattern, newChars);
362
363
  }
363
364
  function chunk(array, chunkSize) {
364
365
  const output = [];
@@ -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, ...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, ...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.8.1",
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",
@@ -46,6 +50,7 @@
46
50
  "test": "mocha --experimental-specifier-resolution=node --no-warnings",
47
51
  "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
48
52
  "clean": "rimraf dist types docs",
49
- "pack": "pnpm pack --pack-destination ../../dist"
53
+ "pack": "pnpm pack --pack-destination ../../dist",
54
+ "lint": "eslint src"
50
55
  }
51
56
  }
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';