@ricsam/isolate-types 0.0.1 → 0.1.3

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,88 @@
1
1
  # @ricsam/isolate-types
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 `@ricsam/isolate-types`
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
+ Type definitions and type-checking utilities for isolate user code.
4
+
5
+ ```bash
6
+ npm add @ricsam/isolate-types
7
+ ```
8
+
9
+ #### Type Checking Isolate Code
10
+
11
+ Validate TypeScript/JavaScript code that will run inside the isolate before execution using `ts-morph`:
12
+
13
+ ```typescript
14
+ import { typecheckIsolateCode } from "@ricsam/isolate-types";
15
+
16
+ const result = typecheckIsolateCode(`
17
+ serve({
18
+ fetch(request, server) {
19
+ const url = new URL(request.url);
20
+
21
+ if (url.pathname === "/ws") {
22
+ server.upgrade(request, { data: { userId: 123 } });
23
+ return new Response(null, { status: 101 });
24
+ }
25
+
26
+ return Response.json({ message: "Hello!" });
27
+ },
28
+ websocket: {
29
+ message(ws, message) {
30
+ ws.send("Echo: " + message);
31
+ }
32
+ }
33
+ });
34
+ `, { include: ["core", "fetch"] });
35
+
36
+ if (!result.success) {
37
+ console.error("Type errors found:");
38
+ for (const error of result.errors) {
39
+ console.error(` Line ${error.line}: ${error.message}`);
40
+ }
41
+ }
42
+ ```
43
+
44
+ **Options:**
45
+
46
+ | Option | Description |
47
+ |--------|-------------|
48
+ | `include` | Which package types to include: `"core"`, `"fetch"`, `"fs"`, `"console"`, `"encoding"`, `"timers"`, `"testEnvironment"` (default: `["core", "fetch", "fs"]`) |
49
+ | `compilerOptions` | Additional TypeScript compiler options |
50
+ | `libraryTypes` | External library type definitions for import resolution (for validating user imports) |
51
+
52
+ **Using with tests:**
53
+
54
+ ```typescript
55
+ import { describe, expect, test } from "node:test";
56
+ import { typecheckIsolateCode } from "@ricsam/isolate-types";
57
+
58
+ describe("Isolate code validation", () => {
59
+ test("server code is type-safe", () => {
60
+ const result = typecheckIsolateCode(userProvidedCode, {
61
+ include: ["fetch"]
62
+ });
63
+ expect(result.success).toBe(true);
64
+ });
65
+ });
66
+ ```
67
+
68
+ #### Type Definition Strings
69
+
70
+ The type definitions are exported as strings for custom use cases:
71
+
72
+ ```typescript
73
+ import {
74
+ CORE_TYPES, // ReadableStream, Blob, File, URL, etc.
75
+ CONSOLE_TYPES, // console.log, console.time, etc.
76
+ CRYPTO_TYPES, // crypto.subtle, CryptoKey, etc.
77
+ ENCODING_TYPES, // atob, btoa
78
+ FETCH_TYPES, // fetch, Request, Response, serve, etc.
79
+ FS_TYPES, // getDirectory, FileSystemHandle, etc.
80
+ PATH_TYPES, // path.join, path.resolve, etc.
81
+ TEST_ENV_TYPES, // describe, it, expect, etc.
82
+ TIMERS_TYPES, // setTimeout, setInterval, etc.
83
+ TYPE_DEFINITIONS // All types as { core, fetch, fs, ... }
84
+ } from "@ricsam/isolate-types";
85
+
86
+ // Use with your own ts-morph project
87
+ project.createSourceFile("isolate-globals.d.ts", FETCH_TYPES);
88
+ ```
@@ -0,0 +1,51 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // packages/isolate-types/src/index.ts
31
+ var exports_src = {};
32
+ __export(exports_src, {
33
+ typecheckIsolateCode: () => import_typecheck.typecheckIsolateCode,
34
+ formatTypecheckErrors: () => import_typecheck.formatTypecheckErrors,
35
+ TYPE_DEFINITIONS: () => import_isolate_types.TYPE_DEFINITIONS,
36
+ TIMERS_TYPES: () => import_isolate_types.TIMERS_TYPES,
37
+ TEST_ENV_TYPES: () => import_isolate_types.TEST_ENV_TYPES,
38
+ PATH_TYPES: () => import_isolate_types.PATH_TYPES,
39
+ FS_TYPES: () => import_isolate_types.FS_TYPES,
40
+ FETCH_TYPES: () => import_isolate_types.FETCH_TYPES,
41
+ ENCODING_TYPES: () => import_isolate_types.ENCODING_TYPES,
42
+ CRYPTO_TYPES: () => import_isolate_types.CRYPTO_TYPES,
43
+ CORE_TYPES: () => import_isolate_types.CORE_TYPES,
44
+ CONSOLE_TYPES: () => import_isolate_types.CONSOLE_TYPES
45
+ });
46
+ module.exports = __toCommonJS(exports_src);
47
+ var import_isolate_types = require("./isolate-types.cjs");
48
+ var import_typecheck = require("./typecheck.cjs");
49
+ })
50
+
51
+ //# debugId=1488BE7FB67324F264756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @ricsam/isolate-types\n *\n * Type definitions and type-checking utilities for isolated-vm V8 sandbox code.\n */\n\n// Re-export type definitions\nexport {\n CORE_TYPES,\n CONSOLE_TYPES,\n CRYPTO_TYPES,\n ENCODING_TYPES,\n FETCH_TYPES,\n FS_TYPES,\n PATH_TYPES,\n TEST_ENV_TYPES,\n TIMERS_TYPES,\n TYPE_DEFINITIONS,\n type TypeDefinitionKey,\n} from \"./isolate-types.cjs\";\n\n// Re-export typecheck utilities\nexport {\n typecheckIsolateCode,\n formatTypecheckErrors,\n type TypecheckResult,\n type TypecheckError,\n type TypecheckOptions,\n type LibraryTypes,\n type LibraryTypeFile,\n} from \"./typecheck.cjs\";\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,IAZP;AAuBO,IARP;",
8
+ "debugId": "1488BE7FB67324F264756E2164756E21",
9
+ "names": []
10
+ }