Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Build Core
run: npm run build:tempo
- name: Run plugin tests
run: npm test --if-present --workspace=@magmacomputing/tempo-plugin-snap --workspace=@magmacomputing/tempo-plugin-batch --workspace=@magmacomputing/tempo-plugin-finance --workspace=@magmacomputing/tempo-plugin-astro --workspace=@magmacomputing/tempo-plugin-sync --workspace=@magmacomputing/tempo-plugin-ticker
run: npm test --if-present --workspace=@magmacomputing/tempo-plugin-snap --workspace=@magmacomputing/tempo-plugin-batch --workspace=@magmacomputing/tempo-plugin-finance --workspace=@magmacomputing/tempo-plugin-astro --workspace=@magmacomputing/tempo-plugin-sync --workspace=@magmacomputing/tempo-plugin-ticker --workspace=@magmacomputing/tempo-plugin-ai
working-directory: packages/plugins

functions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Thumbs.db
**/.vitepress/cache/
**/.vitepress/dist/
**/doc/api/
**/public/api/
**/doc/9-plugins/
# Secrets and credentials
.env
Expand Down
50 changes: 20 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tempo-monorepo",
"version": "3.10.1",
"version": "3.10.2",
"private": true,
"engines": {
"node": ">=20.0.0"
Expand Down
5 changes: 5 additions & 0 deletions packages/library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.10.2] - 2026-07-25

### Fixed
- **Enumify Prototype Integrity**: Hardened the calling context check in the `enumify` constructor to explicitly verify `isFunction(this?.has)`, preventing invalid `Module` objects from corrupting the prototype chain during extension.

## [3.0.0] - 2026-06-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magmacomputing/library",
"version": "3.10.1",
"version": "3.10.2",
"description": "Shared utility library for Tempo",
"author": "Magma Computing Solutions",
"license": "MIT",
Expand Down
29 changes: 12 additions & 17 deletions packages/library/src/common/enumerate.library.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { asType, getType } from '#library/type.library.js';
import { isNumber } from '#library/assertion.library.js';
import { isNumber, isFunction } from '#library/assertion.library.js';
import { ownEntries } from '#library/primitive.library.js';
import { secure, proxify } from '#library/proxy.library.js';
import { Serializable } from '#library/class.library.js';
Expand Down Expand Up @@ -70,27 +70,25 @@ function value(val: any) {
}

/**
* Creates a Proxy-based Registry (Enum) from an Object or Array.
* Enums are immutable (frozen) and provide methods for iteration, search, and extension.
* Arrays are converted to zero-indexed objects (e.g., `['A']` becomes `{ A: 0 }`).
* # Enumify
* create a Proxy-based Registry (Enum) from an Object or Array.
* Enums are immutable (frozen) and provide methods for iteration, search, and extension.
*
* @param list - The array or object to convert into an Enum
* @param frozen - Whether to freeze the resulting Enum (default: true)
* @returns An immutable Enumify registry object
* @example
* ```ts
* ```typescript
* const Status = enumify(['Active', 'Inactive', 'Pending']);
* console.log(Status.Active); // 0
* console.log(Status.has('Active'));// true
* console.log(Status.keys()); // ['Active', 'Inactive', 'Pending']
* console.log(Status.Active); // 0
* console.log(Status.has('Active')); // true
* console.log(Status.keys()); // ['Active', 'Inactive', 'Pending']
* ```
*/
export function enumify<const T extends readonly any[]>(list: T, frozen?: boolean): Enum.wrap<Index<T>>;
export function enumify<const T extends Property<any>>(list: T, frozen?: boolean): Enum.wrap<T>;
export function enumify<T>(this: any, list: T, frozen = true): any {
const proto = (this && getType(this) !== 'Module') ? this : ENUM;
const target = Object.create(proto);
const type = getType(this);
const proto = (type !== 'Module' && isFunction(this?.has)) ? this : ENUM;
const arg = asType(list);
const target = Object.create(proto);

switch (arg.type) {
case 'Enumify':
Expand All @@ -113,10 +111,7 @@ export function enumify<T>(this: any, list: T, frozen = true): any {
return proxify(target, true, frozen); // proxy is ALWAYS frozen (read-only), but target is only 'locked' if requested
}

/**
* A class wrapper for Enumify to register it with the serialization system.
* Allows Enums to be properly serialized and deserialized.
*/
/** create an entry in the Serialization Registry to describe how to rebuild an Enum */
@Serializable
export class Enumify {
constructor(list: Property<any>) {
Expand Down
61 changes: 49 additions & 12 deletions packages/library/test/common/enumerate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,53 @@ describe('enumify stealth proxy', () => {
expect(EXTENDED.values()).toEqual([1, 20, 3]);
});

it('should support Symbol keys in enums', () => {
const sym = Symbol('test');
const MyEnum = enumify({
[sym]: 'symbol-value',
standard: 'string-value'
});

expect(MyEnum.keys()).toContain(sym);
expect(MyEnum.has(sym)).toBe(true);
expect((MyEnum as any)[sym]).toBe('symbol-value');
expect(MyEnum.entries().find(([key]) => key === sym)).toBeDefined();
});
it('should support Symbol keys in enums', () => {
const sym = Symbol('test');
const MyEnum = enumify({
[sym]: 'symbol-value',
standard: 'string-value'
});

expect(MyEnum.keys()).toContain(sym);
expect(MyEnum.has(sym)).toBe(true);
expect((MyEnum as any)[sym]).toBe('symbol-value');
expect(MyEnum.entries().find(([key]) => key === sym)).toBeDefined();
});

describe('caller-context branching', () => {
it('should use safe enum prototype when called with invalid Module context', () => {
const invalidModuleContext = Object.create(null, {
[Symbol.toStringTag]: { value: 'Module' },
has: { value: () => true }
});

const result = enumify.call(invalidModuleContext, { A: 1, B: 2 });

expect(result.A).toBe(1);
expect(result.B).toBe(2);
expect(result.keys()).toEqual(['A', 'B']);
expect(result.values()).toEqual([1, 2]);
expect(result.has('A')).toBe(true);
expect(result.count()).toBe(2);
expect(Object.getPrototypeOf(result)).not.toBe(invalidModuleContext);
});

it('should inherit and expose expected enum methods during normal enum extend flow', () => {
const BASE = enumify({ A: 1, B: 2 });
const EXTENDED = BASE.extend({ C: 3 });

expect(EXTENDED.A).toBe(1);
expect(EXTENDED.B).toBe(2);
expect(EXTENDED.C).toBe(3);
expect(EXTENDED.keys()).toEqual(['A', 'B', 'C']);
expect(EXTENDED.values()).toEqual([1, 2, 3]);
expect(EXTENDED.entries()).toEqual([['A', 1], ['B', 2], ['C', 3]]);
expect(EXTENDED.has('A')).toBe(true);
expect(EXTENDED.has('C')).toBe(true);
expect(EXTENDED.count()).toBe(3);
expect(EXTENDED.invert()).toEqual({ '1': 'A', '2': 'B', '3': 'C' });
expect(typeof EXTENDED.extend).toBe('function');
});
});
});

8 changes: 8 additions & 0 deletions packages/plugins/.setup/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
"plan": "community",
"status": "active"
},
{
"id": "parseAI",
"name": "ParseAI Plugin",
"description": "Tempo community plugin for LLM-powered natural language parsing.",
"packageName": "@magmacomputing/tempo-plugin-ai",
"plan": "community",
"status": "experimental"
},
{
"id": "ticker",
"name": "Ticker Plugin",
Expand Down
27 changes: 26 additions & 1 deletion packages/plugins/.setup/community-plugin-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Ensure the plugin's `package.json` contains the correct community configuration:
}
```
- **Scripts**:
- Ensure `"build": "tsup && tsc"` and `"postbuild": "rm -rf dist/src"` are present.
- Ensure `"build": "tsup && tsc"` is present.
- Include the prepublish safeguard: `"prepublishOnly": "if [ $(git rev-parse --abbrev-ref HEAD) != main ]; then echo 'ERROR: Must be on main branch to publish.'; exit 1; fi && npm run build"`.
- Include the correct test script: `"test": "vitest run -c ../vitest.shared.ts"`.
- **Keywords**: Ensure relevant keywords are present (`tempo`, `tempo-plugin`, `magmacomputing`, `temporal`, `plugin`, etc.).
Expand All @@ -56,6 +56,9 @@ export default defineConfig({
});
```

> [!CAUTION]
> **Never manually override the `format` property** in your `tsup.config.ts` (e.g., `format: ['esm', 'cjs']`). The monorepo's `sharedConfig` is specifically tailored to generate strict ES Modules (`.js`) and Browser IIFE bundles (`.global.min.js`). Adding `'cjs'` will cause the build pipeline to silently overwrite your ESM bundle, breaking Node.js module resolution for users!

And a root `tsconfig.json` that outputs type declarations:

```json
Expand Down Expand Up @@ -109,3 +112,25 @@ Community plugins must follow a uniform documentation standard.

- Rely strictly on open core extensions (`definePlugin`, `defineTerm`).
- While optional, it is highly recommended to provide a short `description` when using `defineTerm` (e.g., `description: 'My custom term'`) so it appears in the `Tempo.terms` registry.

## 6. TypeScript Documentation (TSDoc)

All exported components (functions, interfaces, classes, and types) must be properly documented using the standard Magma TSDoc format. This ensures rich intellisense tooltips for developers utilizing the plugin.

### Format Rules
- Start the block with `/**`
- Provide a markdown header containing the component name (e.g., `* ## MyComponent`)
- Include a descriptive summary
- Document all parameters using `@param` and return types using `@returns`

**Example:**
```typescript
/**
* ## myExportedFunction
* A brief description of what this function does.
*
* @param input - The input value to process
* @returns The successfully processed result
*/
export function myExportedFunction(input: string): string { ... }
```
6 changes: 6 additions & 0 deletions packages/plugins/parseAI/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @magmacomputing/tempo-plugin-ai

## 0.1.0
- Initial scaffolding of the AI natural language parsing plugin.
- Added functional exports for `parseAI`, `initAI`, and `clearAiCache`.
- Drafted initial fallback-routing logic (mocked proxy).
21 changes: 21 additions & 0 deletions packages/plugins/parseAI/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Magma Computing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading