@memberjunction/field-rules-transforms 0.0.1 → 5.44.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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Registers the `jsonpath` and `xpath` transforms into the global FieldTransform registry so any
3
+ * {@link import('@memberjunction/global').FieldTransformEngine} in the process can run them. Idempotent.
4
+ *
5
+ * Importing this package runs it for its side effect, but call it explicitly from a startup/registration
6
+ * path to keep aggressive bundlers from tree-shaking the import away (the MJ `Load*()` convention).
7
+ */
8
+ export declare function RegisterFieldRulesTransforms(): void;
9
+ export { jsonPathTransform } from './jsonpath-transform.js';
10
+ export { xPathTransform } from './xpath-transform.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAOnD;AAKD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ import { RegisterFieldTransform } from '@memberjunction/global';
2
+ import { jsonPathTransform } from './jsonpath-transform.js';
3
+ import { xPathTransform } from './xpath-transform.js';
4
+ let registered = false;
5
+ /**
6
+ * Registers the `jsonpath` and `xpath` transforms into the global FieldTransform registry so any
7
+ * {@link import('@memberjunction/global').FieldTransformEngine} in the process can run them. Idempotent.
8
+ *
9
+ * Importing this package runs it for its side effect, but call it explicitly from a startup/registration
10
+ * path to keep aggressive bundlers from tree-shaking the import away (the MJ `Load*()` convention).
11
+ */
12
+ export function RegisterFieldRulesTransforms() {
13
+ if (registered) {
14
+ return;
15
+ }
16
+ RegisterFieldTransform('jsonpath', jsonPathTransform);
17
+ RegisterFieldTransform('xpath', xPathTransform);
18
+ registered = true;
19
+ }
20
+ // Side-effect registration on import.
21
+ RegisterFieldRulesTransforms();
22
+ export { jsonPathTransform } from './jsonpath-transform.js';
23
+ export { xPathTransform } from './xpath-transform.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IACxC,IAAI,UAAU,EAAE,CAAC;QACb,OAAO;IACX,CAAC;IACD,sBAAsB,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IACtD,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAChD,UAAU,GAAG,IAAI,CAAC;AACtB,CAAC;AAED,sCAAsC;AACtC,4BAA4B,EAAE,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { FieldTransformPlugin } from '@memberjunction/global';
2
+ /**
3
+ * `jsonpath` transform — extracts value(s) from a JSON value via a JSONPath expression.
4
+ *
5
+ * The input may be a JSON string (it is `JSON.parse`d) or an already-parsed object/array. By default the
6
+ * FIRST match is returned (the common "grab one value" case); set `First: false` to get the full array
7
+ * of matches. Lives here, not in `@memberjunction/global`, because it needs `jsonpath-plus`.
8
+ */
9
+ export declare const jsonPathTransform: FieldTransformPlugin;
10
+ //# sourceMappingURL=jsonpath-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonpath-transform.d.ts","sourceRoot":"","sources":["../src/jsonpath-transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,wBAAwB,CAAC;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,oBAQ/B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { JSONPath } from 'jsonpath-plus';
2
+ /**
3
+ * `jsonpath` transform — extracts value(s) from a JSON value via a JSONPath expression.
4
+ *
5
+ * The input may be a JSON string (it is `JSON.parse`d) or an already-parsed object/array. By default the
6
+ * FIRST match is returned (the common "grab one value" case); set `First: false` to get the full array
7
+ * of matches. Lives here, not in `@memberjunction/global`, because it needs `jsonpath-plus`.
8
+ */
9
+ export const jsonPathTransform = (value, _fields, config) => {
10
+ const c = config;
11
+ const json = typeof value === 'string' ? JSON.parse(value) : value;
12
+ const matches = JSONPath({ path: c.Path, json: json, wrap: true });
13
+ if (c.First === false) {
14
+ return matches;
15
+ }
16
+ return Array.isArray(matches) && matches.length > 0 ? matches[0] : null;
17
+ };
18
+ //# sourceMappingURL=jsonpath-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonpath-transform.js","sourceRoot":"","sources":["../src/jsonpath-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9E,MAAM,CAAC,GAAG,MAAwB,CAAC;IACnC,MAAM,IAAI,GAAY,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAc,CAAC;IAC1F,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FieldTransformPlugin } from '@memberjunction/global';
2
+ /**
3
+ * `xpath` transform — extracts value(s) from an XML string via an XPath expression.
4
+ *
5
+ * The input is parsed with `@xmldom/xmldom`. For node-set expressions, each match is reduced to its text
6
+ * (`nodeValue`/`textContent`); for scalar expressions (e.g. `count(...)`, `.../text()`) the scalar is
7
+ * returned. By default the FIRST match is returned; set `First: false` to get the full array. Lives here,
8
+ * not in `@memberjunction/global`, because it needs `xpath` + `@xmldom/xmldom`.
9
+ */
10
+ export declare const xPathTransform: FieldTransformPlugin;
11
+ //# sourceMappingURL=xpath-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath-transform.d.ts","sourceRoot":"","sources":["../src/xpath-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,wBAAwB,CAAC;AAYhF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,oBAS5B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import * as xpath from 'xpath';
2
+ import { DOMParser } from '@xmldom/xmldom';
3
+ /** Coerces an XPath node/result to a scalar value (element/attr text, or the raw scalar). */
4
+ function nodeValue(n) {
5
+ if (n && typeof n === 'object') {
6
+ const node = n;
7
+ if (node.nodeValue != null)
8
+ return node.nodeValue;
9
+ if (node.textContent != null)
10
+ return node.textContent;
11
+ }
12
+ return n;
13
+ }
14
+ /**
15
+ * `xpath` transform — extracts value(s) from an XML string via an XPath expression.
16
+ *
17
+ * The input is parsed with `@xmldom/xmldom`. For node-set expressions, each match is reduced to its text
18
+ * (`nodeValue`/`textContent`); for scalar expressions (e.g. `count(...)`, `.../text()`) the scalar is
19
+ * returned. By default the FIRST match is returned; set `First: false` to get the full array. Lives here,
20
+ * not in `@memberjunction/global`, because it needs `xpath` + `@xmldom/xmldom`.
21
+ */
22
+ export const xPathTransform = (value, _fields, config) => {
23
+ const c = config;
24
+ const doc = new DOMParser().parseFromString(String(value ?? ''), 'text/xml');
25
+ const result = xpath.select(c.Path, doc);
26
+ if (Array.isArray(result)) {
27
+ const values = result.map(nodeValue);
28
+ return c.First === false ? values : (values.length > 0 ? values[0] : null);
29
+ }
30
+ return result ?? null; // string / number / boolean (e.g. count(), normalize-space())
31
+ };
32
+ //# sourceMappingURL=xpath-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath-transform.js","sourceRoot":"","sources":["../src/xpath-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,6FAA6F;AAC7F,SAAS,SAAS,CAAC,CAAU;IACzB,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,CAA+D,CAAC;QAC7E,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC;QAClD,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1D,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAC3E,MAAM,CAAC,GAAG,MAAqB,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,GAAsB,CAAC,CAAC;IAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,8DAA8D;AACzF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,34 @@
1
1
  {
2
2
  "name": "@memberjunction/field-rules-transforms",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @memberjunction/field-rules-transforms",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "type": "module",
4
+ "version": "5.44.0",
5
+ "description": "MemberJunction: extended field-rules transform plugins (jsonpath, xpath) that register into the @memberjunction/global FieldTransform registry. Owns the heavier parsing libraries so global stays dependency-light.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "/dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc && tsc-alias -f",
13
+ "watch": "tsc --watch",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest"
16
+ },
17
+ "author": "MemberJunction.com",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "@memberjunction/global": "5.44.0",
21
+ "@xmldom/xmldom": "^0.8.11",
22
+ "jsonpath-plus": "^10.3.0",
23
+ "xpath": "^0.0.34"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "24.10.11",
27
+ "typescript": "^5.9.3",
28
+ "vitest": "^3.1.1"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/MemberJunction/MJ"
33
+ }
10
34
  }
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # @memberjunction/field-rules-transforms
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@memberjunction/field-rules-transforms`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**