@bernierllc/nevar-mixin-bridge 0.0.1 → 0.1.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.
package/README.md CHANGED
@@ -1,45 +1,105 @@
1
1
  # @bernierllc/nevar-mixin-bridge
2
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 `@bernierllc/nevar-mixin-bridge`
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**
3
+ Mixin definition utilities for the Nevar rules engine. Allows domain-specific extensions to register triggers, operators, actions, and context providers onto a Nevar instance under a namespace.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @bernierllc/nevar-mixin-bridge
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { defineMixin } from '@bernierllc/nevar-mixin-bridge';
15
+ import type { MixinDefinition } from '@bernierllc/nevar-mixin-bridge';
16
+ import { z } from 'zod';
17
+
18
+ const ecommerceMixin = defineMixin('ecommerce', {
19
+ triggers: [
20
+ {
21
+ key: 'order.placed',
22
+ payloadSchema: z.object({ orderId: z.string(), total: z.number() }),
23
+ description: 'Fires when an order is placed',
24
+ category: 'commerce',
25
+ },
26
+ ],
27
+ operators: [
28
+ {
29
+ name: 'currency_gt',
30
+ definition: {
31
+ label: 'Currency Greater Than',
32
+ category: 'commerce',
33
+ evaluate: (field, target) => Number(field) > Number(target),
34
+ schema: z.number(),
35
+ fieldTypes: ['number'],
36
+ },
37
+ },
38
+ ],
39
+ actions: [
40
+ {
41
+ actionType: 'send-receipt',
42
+ definition: {
43
+ execute: async (config, context) => {
44
+ // Send receipt logic
45
+ return { sent: true };
46
+ },
47
+ },
48
+ },
49
+ ],
50
+ contextProviders: [
51
+ {
52
+ prefix: 'order',
53
+ provider: async (payload) => ({
54
+ total: 99.99,
55
+ currency: 'USD',
56
+ }),
57
+ },
58
+ ],
59
+ methods: {
60
+ getOrderStatus: (orderId: string) => 'shipped',
61
+ },
62
+ });
63
+
64
+ // Apply to a Nevar instance
65
+ ecommerceMixin(nevar);
66
+
67
+ // Methods are accessible under the namespace
68
+ // nevar.ecommerce.getOrderStatus('order-1')
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### `defineMixin(namespace, definition)`
74
+
75
+ Creates a mixin function that can be applied to a Nevar instance. The returned function registers all triggers, operators, actions, and context providers defined in the mixin, and mounts any methods at `nevar[namespace]`.
76
+
77
+ **Parameters:**
78
+ - `namespace: string` - The namespace to mount methods under
79
+ - `definition: MixinDefinition` - The mixin definition containing triggers, operators, actions, context providers, and methods
80
+
81
+ **Returns:** `(nevar: NevarLike) => void` - A function that applies the mixin to a Nevar instance
82
+
83
+ **Throws:** `NevarValidationError` if the namespace is already registered on the instance.
84
+
85
+ ### Types
86
+
87
+ - `MixinDefinition` - Complete mixin definition with optional `triggers`, `operators`, `actions`, `contextProviders`, and `methods`
88
+ - `MixinTrigger` - Trigger definition with `key`, `payloadSchema`, optional `description` and `category`
89
+ - `MixinOperator` - Operator definition with `name` and `definition: OperatorDefinition`
90
+ - `MixinAction` - Action definition with `actionType` and `definition: ActionHandlerDefinition`
91
+ - `MixinContextProvider` - Context provider with `prefix` and `provider` function
92
+ - `ActionHandlerDefinition` - Action handler with `execute` function and optional `description`
93
+ - `NevarLike` - Minimal interface for a Nevar instance that supports registration methods
94
+
95
+ ## Integration Documentation
96
+
97
+ ### Logger Integration
98
+ This package does not integrate with `@bernierllc/logger`. As a core package, logger integration is optional and not included by default. Consumers should handle logging at the service layer.
99
+
100
+ ### NeverHub Integration
101
+ This package does not integrate with `@bernierllc/neverhub-adapter`. As a core package, NeverHub integration is not applicable. NeverHub registration should be handled by service-layer packages that compose this package.
102
+
103
+ ## License
104
+
105
+ Copyright (c) 2025 Bernier LLC. All rights reserved.
@@ -0,0 +1,73 @@
1
+ import { OperatorDefinition } from '@bernierllc/nevar-types';
2
+ /**
3
+ * Definition for an action handler that a mixin can register.
4
+ */
5
+ export interface ActionHandlerDefinition {
6
+ execute: (config: Record<string, unknown>, context: Record<string, unknown>) => Promise<Record<string, unknown>>;
7
+ description?: string;
8
+ }
9
+ /**
10
+ * A trigger definition within a mixin.
11
+ */
12
+ export interface MixinTrigger {
13
+ key: string;
14
+ payloadSchema: unknown;
15
+ description?: string;
16
+ category?: string;
17
+ }
18
+ /**
19
+ * An operator definition within a mixin.
20
+ */
21
+ export interface MixinOperator {
22
+ name: string;
23
+ definition: OperatorDefinition;
24
+ }
25
+ /**
26
+ * An action definition within a mixin.
27
+ */
28
+ export interface MixinAction {
29
+ actionType: string;
30
+ definition: ActionHandlerDefinition;
31
+ }
32
+ /**
33
+ * A context provider definition within a mixin.
34
+ */
35
+ export interface MixinContextProvider {
36
+ prefix: string;
37
+ provider: (payload: Record<string, unknown>) => Promise<Record<string, unknown>> | Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Complete mixin definition describing triggers, operators, actions,
41
+ * context providers, and methods to register on a Nevar instance.
42
+ */
43
+ export interface MixinDefinition {
44
+ triggers?: MixinTrigger[];
45
+ operators?: MixinOperator[];
46
+ actions?: MixinAction[];
47
+ contextProviders?: MixinContextProvider[];
48
+ methods?: Record<string, Function>;
49
+ }
50
+ /**
51
+ * Minimal interface describing a Nevar-like instance that supports
52
+ * registration of operators, triggers, actions, and context providers.
53
+ */
54
+ export interface NevarLike {
55
+ registerOperator(name: string, def: OperatorDefinition): void;
56
+ registerTrigger(key: string, def: Record<string, unknown>): void;
57
+ registerAction(type: string, def: ActionHandlerDefinition): void;
58
+ registerContextProvider(prefix: string, fn: (payload: Record<string, unknown>) => Promise<Record<string, unknown>> | Record<string, unknown>): void;
59
+ [key: string]: unknown;
60
+ }
61
+ /**
62
+ * Defines a mixin function that can be applied to a Nevar instance.
63
+ *
64
+ * The returned function will:
65
+ * 1. Check for namespace conflicts on the Nevar instance
66
+ * 2. Register all triggers, operators, actions, and context providers
67
+ * 3. Mount any methods at `nevar[namespace]`
68
+ *
69
+ * @param namespace - The namespace to mount methods under
70
+ * @param definition - The mixin definition
71
+ * @returns A function that applies the mixin to a NevarLike instance
72
+ */
73
+ export declare function defineMixin(namespace: string, definition: MixinDefinition): (nevar: NevarLike) => void;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.defineMixin = defineMixin;
11
+ const nevar_types_1 = require("@bernierllc/nevar-types");
12
+ /**
13
+ * Defines a mixin function that can be applied to a Nevar instance.
14
+ *
15
+ * The returned function will:
16
+ * 1. Check for namespace conflicts on the Nevar instance
17
+ * 2. Register all triggers, operators, actions, and context providers
18
+ * 3. Mount any methods at `nevar[namespace]`
19
+ *
20
+ * @param namespace - The namespace to mount methods under
21
+ * @param definition - The mixin definition
22
+ * @returns A function that applies the mixin to a NevarLike instance
23
+ */
24
+ function defineMixin(namespace, definition) {
25
+ return (nevar) => {
26
+ // Check for namespace conflict
27
+ if (nevar[namespace] !== undefined) {
28
+ throw new nevar_types_1.NevarValidationError(`Mixin namespace "${namespace}" is already registered on this Nevar instance`, {
29
+ code: 'NEVAR_MIXIN_NAMESPACE_CONFLICT',
30
+ context: { namespace },
31
+ });
32
+ }
33
+ if (definition.triggers) {
34
+ for (const trigger of definition.triggers) {
35
+ nevar.registerTrigger(trigger.key, {
36
+ key: trigger.key,
37
+ description: trigger.description,
38
+ schema: trigger.payloadSchema,
39
+ metadata: trigger.category ? { category: trigger.category } : undefined,
40
+ });
41
+ }
42
+ }
43
+ if (definition.operators) {
44
+ for (const operator of definition.operators) {
45
+ nevar.registerOperator(operator.name, operator.definition);
46
+ }
47
+ }
48
+ if (definition.actions) {
49
+ for (const action of definition.actions) {
50
+ nevar.registerAction(action.actionType, action.definition);
51
+ }
52
+ }
53
+ if (definition.contextProviders) {
54
+ for (const cp of definition.contextProviders) {
55
+ nevar.registerContextProvider(cp.prefix, cp.provider);
56
+ }
57
+ }
58
+ nevar[namespace] = { ...definition.methods };
59
+ };
60
+ }
@@ -0,0 +1,2 @@
1
+ export { defineMixin } from './define-mixin';
2
+ export type { MixinDefinition, MixinTrigger, MixinOperator, MixinAction, MixinContextProvider, ActionHandlerDefinition, NevarLike, } from './define-mixin';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.defineMixin = void 0;
11
+ var define_mixin_1 = require("./define-mixin");
12
+ Object.defineProperty(exports, "defineMixin", { enumerable: true, get: function () { return define_mixin_1.defineMixin; } });
package/package.json CHANGED
@@ -1,10 +1,56 @@
1
1
  {
2
2
  "name": "@bernierllc/nevar-mixin-bridge",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @bernierllc/nevar-mixin-bridge",
3
+ "version": "0.1.0",
4
+ "description": "Utilities for building withX() mixin functions for the Nevar rules engine",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
5
12
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
13
+ "nevar",
14
+ "rules-engine",
15
+ "mixin",
16
+ "mixin-bridge",
17
+ "plugin"
18
+ ],
19
+ "author": "Bernier LLC",
20
+ "license": "SEE LICENSE IN LICENSE",
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
25
+ "engines": {
26
+ "node": ">=16.0.0"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/bernierllc/tools.git",
31
+ "directory": "packages/core/nevar-mixin-bridge"
32
+ },
33
+ "dependencies": {
34
+ "@bernierllc/nevar-types": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/jest": "^29.5.0",
38
+ "@types/node": "^20.0.0",
39
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
40
+ "@typescript-eslint/parser": "^6.0.0",
41
+ "eslint": "^8.0.0",
42
+ "jest": "^29.5.0",
43
+ "rimraf": "^5.0.0",
44
+ "ts-jest": "^29.1.0",
45
+ "typescript": "^5.0.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "prebuild": "npm run clean",
50
+ "clean": "rimraf dist",
51
+ "test": "jest",
52
+ "test:run": "jest",
53
+ "test:coverage": "jest --coverage",
54
+ "lint": "eslint src __tests__ --ext .ts"
55
+ }
56
+ }