@pulse-compute/wasm-contracts 1.0.0-beta.2 → 1.0.0-beta.4

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
@@ -7,9 +7,9 @@
7
7
  > **Supported entry points:** `@pulse-compute/wasm-contracts/provider/toolchain`<br>
8
8
  > **Stability:** The provider toolchain contract is versioned and supported for the Beta; other protocol and proof interfaces remain internal.<br>
9
9
  > **npm:** [`@pulse-compute/wasm-contracts`](https://www.npmjs.com/package/@pulse-compute/wasm-contracts)<br>
10
- > **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.2/packages/implementation-packages/)
10
+ > **Canonical documentation:** [Package guide](https://pulsecompute.io/v1.0.0-beta.4/packages/implementation-packages/)
11
11
  >
12
- > This release-status block is generated from the synchronized `Pulse 1.0.0-beta.2` package policy.
12
+ > This release-status block is generated from the synchronized `Pulse 1.0.0-beta.4` package policy.
13
13
  <!-- pulse-package-status:end -->
14
14
 
15
15
  This package owns stable data contracts shared by the compiler, runtime, and providers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-compute/wasm-contracts",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "license": "Apache-2.0",
5
5
  "engines": {
6
6
  "node": "^22.14.0 || ^24.0.0"
@@ -126,7 +126,7 @@
126
126
  "url": "git+https://github.com/pulse-compute/pulse.git",
127
127
  "directory": "wasm/packages/contracts"
128
128
  },
129
- "homepage": "https://pulsecompute.io/v1.0.0-beta.2/packages/implementation-packages/",
129
+ "homepage": "https://pulsecompute.io/v1.0.0-beta.4/packages/implementation-packages/",
130
130
  "bugs": {
131
131
  "url": "https://github.com/pulse-compute/pulse/issues"
132
132
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  const path = require('node:path');
4
4
 
5
- const PACKAGE_VERSION = 'pulsewasm-route-extractor@1.0.0-beta.2';
5
+ const PACKAGE_VERSION = 'pulsewasm-route-extractor@1.0.0-beta.4';
6
6
  const DIAGNOSTICS_VERSION = 'pulsewasm.diagnostics.v1';
7
7
 
8
8
  function stableFileName(fileName, cwd) {
@@ -46,6 +46,7 @@ const CANONICAL_NATIVE_INTRINSICS = Object.freeze([
46
46
  'request.text',
47
47
  'request.json',
48
48
  'response.json',
49
+ 'schema.encode.text',
49
50
  'response.text',
50
51
  'response.custom',
51
52
  'kv.namespace',
@@ -74,6 +74,7 @@ const CANONICAL_NATIVE_IMPORTS = Object.freeze([
74
74
  ['router_match', ['i32', 'i32'], ['i32']],
75
75
  ['router_param', ['i32', 'i32', 'i32'], ['i32']],
76
76
  ['response_json', ['i32', 'i32'], ['i32']],
77
+ ['schema_encode', ['i32', 'i32'], ['i32']],
77
78
  ['response_text', ['i32', 'i32'], ['i32']],
78
79
  ['response_custom', ['i32'], ['i32']],
79
80
  ['grip_is_websocket', [], ['i32']],
@@ -6,7 +6,7 @@ const CTX_CONTRACT_VERSION = 'pulse.ctx-contract.v4';
6
6
  const CTX_CONTRACT_ID = 'pulse.ctx';
7
7
  const CTX_SURFACE_IDS = Object.freeze([
8
8
  'ctx.param','ctx.req.method','ctx.req.url','ctx.req.path','ctx.req.header','ctx.req.headers',
9
- 'ctx.state.get','ctx.state.set','ctx.json','ctx.text','ctx.response','ctx.req.text','ctx.req.json.schema',
9
+ 'ctx.state.get','ctx.state.set','ctx.encodeJson','ctx.json','ctx.text','ctx.response','ctx.req.text','ctx.req.json.schema',
10
10
  'ctx.req.json.generic','ctx.fetch.projected','ctx.fetch.opaque-return','ctx.config.get','ctx.secret.get',
11
11
  'ctx.kv.get','ctx.kv.put','ctx.kv.getVersioned','ctx.kv.insertIfAbsent','ctx.kv.compareAndSwap','ctx.emit','package.operation'
12
12
  ]);
@@ -33,7 +33,7 @@ function defaultCtxContract() {
33
33
  handlerSurfaceVersion: HANDLER_SURFACE_CONTRACT_VERSION,
34
34
  surfaces: CTX_SURFACES,
35
35
  planes: Object.freeze({
36
- sharedAuthoring: Object.freeze(['state', 'log', 'fetch', 'parallel', 'config', 'secret', 'kv', 'emit']),
36
+ sharedAuthoring: Object.freeze(['state', 'log', 'fetch', 'parallel', 'config', 'secret', 'kv', 'emit', 'encodeJson']),
37
37
  httpAuthoring: Object.freeze(['req', 'json', 'text', 'response']),
38
38
  routeAuthoring: Object.freeze(['param']),
39
39
  eventAuthoring: Object.freeze(['event.type', 'event.payload']),
@@ -212,6 +212,18 @@ const HANDLER_SURFACE_DEFINITIONS = Object.freeze([
212
212
  nativeBehavior: 'construct-canonical-result',
213
213
  status: 'existing-alias-normalization'
214
214
  }),
215
+ surface({
216
+ id: 'ctx.encodeJson',
217
+ class: 'sync',
218
+ canonicalOperation: 'schema.encode.text',
219
+ publicForms: ["ctx.encodeJson(value, 'schema.id')"],
220
+ awaitPolicy: 'optional-redundant-warning',
221
+ validPositions: ['expression', 'statement', 'return'],
222
+ targetSupport: { javascript: true, native: true },
223
+ nativeBehavior: 'schema-validated-bounded-json-text',
224
+ schemaPolicy: 'literal-schema-required',
225
+ status: 'supported'
226
+ }),
215
227
  surface({
216
228
  id: 'ctx.text',
217
229
  class: 'sync',
@@ -20,7 +20,7 @@ function defaultHandlerTypesContract() {
20
20
  set: 'void'
21
21
  }),
22
22
  executionContexts: Object.freeze({
23
- shared: Object.freeze(['state', 'log', 'fetch', 'parallel', 'config', 'secret', 'kv', 'emit']),
23
+ shared: Object.freeze(['state', 'log', 'fetch', 'parallel', 'config', 'secret', 'kv', 'emit', 'encodeJson']),
24
24
  http: Object.freeze(['req', 'json', 'text', 'response']),
25
25
  route: Object.freeze(['param']),
26
26
  event: Object.freeze(['event.type', 'event.payload']),
@@ -51,6 +51,7 @@ const DRIVER_FIELDS = Object.freeze([
51
51
  'events',
52
52
  'targets',
53
53
  'execute',
54
+ 'prepareNativeExecution',
54
55
  'createLoweringPlan',
55
56
  'inspectRealization',
56
57
  'writeTarget',
@@ -366,6 +367,9 @@ function defineProviderDriver(input, expected = {}) {
366
367
  if ((targets.native && (targets.native.commands.test || targets.native.commands.dev)) && typeof input.execute !== 'function') {
367
368
  throw new TypeError(`Pulse provider driver ${id} is missing execute().`);
368
369
  }
370
+ if (input.prepareNativeExecution !== undefined && typeof input.prepareNativeExecution !== 'function') {
371
+ throw new TypeError(`Pulse provider driver ${id} prepareNativeExecution must be a function.`);
372
+ }
369
373
  const descriptor = input.descriptor === undefined ? undefined : normalizeDescriptor(input.descriptor);
370
374
  if (descriptor && descriptor.id !== id) throw new TypeError(`Pulse provider driver ${id} descriptor identity does not match.`);
371
375
  const javascript = normalizeJavascriptDriver(input.javascript, targets.javascript);
@@ -392,6 +396,7 @@ function defineProviderDriver(input, expected = {}) {
392
396
  events,
393
397
  targets,
394
398
  execute: input.execute,
399
+ prepareNativeExecution: input.prepareNativeExecution,
395
400
  createLoweringPlan: input.createLoweringPlan,
396
401
  inspectRealization: input.inspectRealization,
397
402
  writeTarget: input.writeTarget,
@@ -622,7 +627,7 @@ function createProviderTargetInvocation(input) {
622
627
  throw new TypeError(`Pulse provider target invocation version must be ${PROVIDER_TARGET_INVOCATION_VERSION}.`);
623
628
  }
624
629
  const action = nonEmpty(input.action, 'invocation action');
625
- if (!['inspect-native', 'write-native', 'write-javascript'].includes(action)) {
630
+ if (!['inspect-native', 'write-native', 'write-javascript', 'execute-native'].includes(action)) {
626
631
  throw new TypeError(`Pulse provider target invocation action ${action} is unsupported.`);
627
632
  }
628
633
  const target = action.endsWith('javascript') ? 'javascript' : 'native';
@@ -9,10 +9,11 @@ const JSON_TRACE_EVENT_KINDS = Object.freeze([
9
9
  'json.decode.fetch',
10
10
  'json.encode.response',
11
11
  'json.encode.fetch',
12
+ 'json.encode.value',
12
13
  'json.decode.error',
13
14
  'json.encode.error'
14
15
  ]);
15
- const JSON_BOUNDARIES = Object.freeze(['request', 'fetch-response', 'application-response', 'fetch-request']);
16
+ const JSON_BOUNDARIES = Object.freeze(['request', 'fetch-response', 'application-response', 'fetch-request', 'application-value']);
16
17
  const JSON_BODY_OWNERSHIP = Object.freeze([
17
18
  'request-snapshot',
18
19
  'fetched-response-snapshot',
@@ -24,8 +25,9 @@ const JSON_EVENT_BOUNDARIES = Object.freeze({
24
25
  'json.decode.fetch': Object.freeze(['fetch-response']),
25
26
  'json.encode.response': Object.freeze(['application-response']),
26
27
  'json.encode.fetch': Object.freeze(['fetch-request']),
28
+ 'json.encode.value': Object.freeze(['application-value']),
27
29
  'json.decode.error': Object.freeze(['request', 'fetch-response']),
28
- 'json.encode.error': Object.freeze(['application-response', 'fetch-request'])
30
+ 'json.encode.error': Object.freeze(['application-response', 'fetch-request', 'application-value'])
29
31
  });
30
32
 
31
33
  function traceError(code, message, details = {}) {