@chainlink/cre-sdk 0.0.6-alpha → 0.0.7-alpha

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,83 @@
1
+ // Global type declarations for the CRE SDK runtime
2
+ // Those are the methods that the Host exposes to the Guest.
3
+
4
+ /**
5
+ * Host functions exposed by the CRE runtime to WASM guests
6
+ */
7
+ declare global {
8
+ /**
9
+ * Initiates an asynchronous capability call
10
+ * @param request - protobuf request as bytes
11
+ * @returns Callback ID for the async operation
12
+ */
13
+ function callCapability(request: Uint8Array): number
14
+
15
+ /**
16
+ * Awaits completion of async capability calls
17
+ * @param awaitRequest - protobuf await request as bytes
18
+ * @param maxResponseLen - Maximum response size in bytes
19
+ * @returns response as bytes
20
+ */
21
+ function awaitCapabilities(awaitRequest: Uint8Array, maxResponseLen: number): Uint8Array
22
+
23
+ /**
24
+ * Gets secrets asynchronously
25
+ * @param request - protobuf secret request as bytes
26
+ * @param maxResponseLen - Maximum response size in bytes
27
+ * @returns Callback ID for the async operation
28
+ */
29
+ function getSecrets(request: Uint8Array, maxResponseLen: number): number
30
+
31
+ /**
32
+ * Awaits completion of async secret requests
33
+ * @param awaitRequest - protobuf await secret request as bytes
34
+ * @param maxResponseLen - Maximum response size in bytes
35
+ * @returns response as bytes
36
+ */
37
+ function awaitSecrets(awaitRequest: Uint8Array, maxResponseLen: number): Uint8Array
38
+
39
+ /**
40
+ * Logs a message to the host runtime
41
+ * @param message - The message to log
42
+ */
43
+ function log(message: string): void
44
+
45
+ /**
46
+ * Sends a response back to the host
47
+ * @param response - bytes response
48
+ * @returns Status code (0 for success)
49
+ */
50
+ function sendResponse(response: Uint8Array): number
51
+
52
+ /**
53
+ * Switches execution mode between NODE and DON
54
+ * @param mode - The mode to switch to (0 = UNSPECIFIED, 1 = DON, 2 = NODE)
55
+ */
56
+ function switchModes(mode: 0 | 1 | 2): void
57
+
58
+ /**
59
+ * Indicates this is a V2 SDK workflow
60
+ */
61
+ function versionV2(): void
62
+
63
+ /**
64
+ * Gets a random seed from the host
65
+ * @param mode - 1 for non-deterministic, 2 for deterministic
66
+ * @returns Random seed value
67
+ */
68
+ function randomSeed(mode: 1 | 2): number
69
+
70
+ /**
71
+ * Gets WASI command line arguments
72
+ * @returns Serialized arguments
73
+ */
74
+ function getWasiArgs(): string
75
+
76
+ /**
77
+ * Gets the current time from the host runtime
78
+ * @returns Unix timestamp in milliseconds
79
+ */
80
+ function now(): number
81
+ }
82
+
83
+ export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainlink/cre-sdk",
3
- "version": "0.0.6-alpha",
3
+ "version": "0.0.7-alpha",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "import": "./dist/index.js"
11
11
  },
12
12
  "./restricted-apis": {
13
- "types": "./dist/restricted-apis.d.ts"
13
+ "types": "./dist/sdk/types/restricted-apis.d.ts"
14
14
  },
15
15
  "./pb": {
16
16
  "types": "./dist/pb.d.ts",
@@ -1,22 +1,33 @@
1
1
  import { glob } from 'fast-glob'
2
2
  import { copyFile, mkdir } from 'fs/promises'
3
- import { dirname, join, relative } from 'path'
3
+ import { join } from 'path'
4
4
 
5
5
  const buildTypes = async () => {
6
- console.log('🔧 Including restricted-apis type in built files...')
6
+ console.log('🔧 Copying type definition files to dist...')
7
7
 
8
8
  // Define paths relative to the scripts directory
9
9
  const packageRoot = join(import.meta.dir, '../..')
10
- const sourceFile = join(packageRoot, 'src/sdk/types/restricted-apis.d.ts')
11
- const destFile = join(packageRoot, 'dist/restricted-apis.d.ts')
10
+ const sourceDir = join(packageRoot, 'src/sdk/types')
11
+ const destDir = join(packageRoot, 'dist/sdk/types')
12
12
 
13
- // Ensure the dist directory exists
14
- await mkdir(dirname(destFile), { recursive: true })
13
+ // Ensure the destination directory exists
14
+ await mkdir(destDir, { recursive: true })
15
15
 
16
- // Copy the file
17
- await copyFile(sourceFile, destFile)
16
+ // Find all .d.ts files in the source directory
17
+ const typeFiles = await glob('*.d.ts', {
18
+ cwd: sourceDir,
19
+ absolute: false,
20
+ })
18
21
 
19
- console.log('✅ Included restricted-apis type in the build.')
22
+ // Copy each file
23
+ for (const file of typeFiles) {
24
+ const sourceFile = join(sourceDir, file)
25
+ const destFile = join(destDir, file)
26
+ await copyFile(sourceFile, destFile)
27
+ console.log(` ✓ Copied ${file}`)
28
+ }
29
+
30
+ console.log(`✅ Copied ${typeFiles.length} type definition file(s) to dist/sdk/types`)
20
31
  }
21
32
 
22
33
  export const main = buildTypes