@deepraxis/sdk 0.1.1-dev.b0da55b → 0.1.1-dev.b0e15c2

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
@@ -10,7 +10,7 @@ The official TypeScript SDK for [Praxis](https://deepraxis.com), the cloud where
10
10
  [![Bundle size](https://img.shields.io/bundlephobia/minzip/@deepraxis/sdk?color=2e8555)](https://bundlephobia.com/package/@deepraxis/sdk)
11
11
  [![License](https://img.shields.io/badge/license-Apache--2.0-2e8555)](https://www.apache.org/licenses/LICENSE-2.0)
12
12
 
13
- [Website](https://deepraxis.com) · [Documentation](https://docs.deepraxis.com) · [API reference](https://docs.deepraxis.com/docs/api) · [Console](https://console.deepraxis.com)
13
+ [Website](https://deepraxis.com) · [Documentation](https://docs.deepraxis.com) · [API reference](https://docs.deepraxis.com/api) · [Console](https://console.deepraxis.com)
14
14
 
15
15
  </div>
16
16
 
@@ -262,13 +262,14 @@ export default async (input: { prompt: string }) => {
262
262
 
263
263
  Keep your code and point the official SDK at Praxis by changing `baseURL`, for example
264
264
  `https://api.deepraxis.com/openai/v1` for the OpenAI SDK. The
265
- [SDK cookbook](https://docs.deepraxis.com/docs/cookbook/sdk) has the details for OpenAI,
266
- Anthropic, the Vercel AI SDK and LangChain. This SDK covers what those don't: agents,
265
+ [OpenAI-compatible](https://docs.deepraxis.com/en/developers/model/guides/openai-compatible) and
266
+ [Anthropic-compatible](https://docs.deepraxis.com/en/developers/model/guides/anthropic-compatible)
267
+ guides have the details. This SDK covers what those don't: agents,
267
268
  sandboxes, search, data, automation and the rest of the platform.
268
269
 
269
270
  ## Resources
270
271
 
271
- - [Documentation](https://docs.deepraxis.com) and [API reference](https://docs.deepraxis.com/docs/api)
272
+ - [Documentation](https://docs.deepraxis.com) and [API reference](https://docs.deepraxis.com/api)
272
273
  - [METHODS.md](https://unpkg.com/@deepraxis/sdk/METHODS.md): every method, its HTTP route, and whether it streams or paginates
273
274
  - [Praxis CLI](https://www.npmjs.com/package/@deepraxis/cli): the same API from your terminal
274
275
 
@@ -0,0 +1,3 @@
1
+ import type { Operation } from './transport.js';
2
+ /** Whether this operation's 200 response is the declared bytes of the resource, not a JSON body. */
3
+ export declare function isBinaryOperation(operation: Operation): boolean;
@@ -0,0 +1,14 @@
1
+ import * as sdk from "../generated/sdk.gen.js";
2
+ import { binaryOperations } from "../generated/binary-operations.gen.js";
3
+ /**
4
+ * The generated SDK operations whose success response the OpenAPI declares as binary bytes
5
+ * (generated from the spec into `binary-operations.gen.ts`). Resolved by function identity, so
6
+ * wrapping, renaming or minification cannot change the answer.
7
+ */
8
+ const binary = new Set(binaryOperations
9
+ .map(name => sdk[name])
10
+ .filter((operation) => typeof operation === 'function'));
11
+ /** Whether this operation's 200 response is the declared bytes of the resource, not a JSON body. */
12
+ export function isBinaryOperation(operation) {
13
+ return binary.has(operation);
14
+ }
@@ -0,0 +1,11 @@
1
+ /** Deprecated SDK methods warn once per process per method (ticket-4078). The table is generated from the
2
+ * OpenAPI `deprecated: true` operations; this is the single call path every deprecated binding goes through. */
3
+ export interface DeprecationNotice {
4
+ readonly replacement: string;
5
+ readonly sunset: string;
6
+ }
7
+ export declare function deprecationMessage(method: string, notice: DeprecationNotice): string;
8
+ /** Test seam: forget which methods already warned. */
9
+ export declare function resetDeprecationWarnings(): void;
10
+ export declare function envSilencesDeprecations(): boolean;
11
+ export declare function deprecate<F extends (...args: any[]) => any>(silenced: () => boolean, method: string, notice: DeprecationNotice, fn: F): F;
@@ -0,0 +1,20 @@
1
+ const warned = new Set();
2
+ export function deprecationMessage(method, notice) {
3
+ return `${method} is deprecated and stops working on ${notice.sunset}; use ${notice.replacement} instead.`;
4
+ }
5
+ /** Test seam: forget which methods already warned. */
6
+ export function resetDeprecationWarnings() { warned.clear(); }
7
+ export function envSilencesDeprecations() {
8
+ const env = globalThis.process?.env;
9
+ const value = env?.PRAXIS_SDK_SILENCE_DEPRECATIONS;
10
+ return value !== undefined && value !== '' && value !== '0' && value !== 'false';
11
+ }
12
+ export function deprecate(silenced, method, notice, fn) {
13
+ return ((...args) => {
14
+ if (!warned.has(method) && !silenced()) {
15
+ warned.add(method);
16
+ console.warn(deprecationMessage(method, notice));
17
+ }
18
+ return fn(...args);
19
+ });
20
+ }
@@ -6,6 +6,8 @@ export interface PraxisOptions {
6
6
  timeoutMs?: number;
7
7
  maxRetries?: number;
8
8
  fetch?: typeof globalThis.fetch;
9
+ /** Silence the once-per-method warning a deprecated method prints. PRAXIS_SDK_SILENCE_DEPRECATIONS=1 does the same. */
10
+ silenceDeprecations?: boolean;
9
11
  }
10
12
  export interface RequestOptions {
11
13
  headers?: Record<string, string>;
@@ -37,6 +39,8 @@ export declare function serverDeadlineMs(options: {
37
39
  export declare class Transport {
38
40
  private readonly config;
39
41
  constructor(options: PraxisOptions);
42
+ /** Whether deprecated-method warnings are off (client option or PRAXIS_SDK_SILENCE_DEPRECATIONS). */
43
+ readonly silenced: () => boolean;
40
44
  private validate;
41
45
  private scope;
42
46
  request<R>(operation: Operation, options?: InternalOptions): Promise<R>;
@@ -3,6 +3,8 @@ import { PraxisError, PraxisTimeoutError } from "./errors.js";
3
3
  import { abortable, fetchWithRetry } from "./retry.js";
4
4
  import { parseSSE } from "./sse.js";
5
5
  import { resolveDefaultCredentials } from "./credentials.js";
6
+ import { isBinaryOperation } from "./binary-operations.js";
7
+ import { envSilencesDeprecations } from "./deprecation.js";
6
8
  /** Our own per-call keys, beyond what the generated hey-api client accepts. */
7
9
  const SDK_OPTION_KEYS = ['timeoutMs', 'maxRetries', 'stream', 'lastEventId'];
8
10
  /** Every key of the generated client's per-call RequestOptions (request parts, fetch/RequestInit, serializers,
@@ -49,13 +51,15 @@ export class Transport {
49
51
  this.config = { timeoutMs: 600_000, maxRetries: 2, fetch: globalThis.fetch, ...options };
50
52
  this.validate(this.config.timeoutMs, this.config.maxRetries);
51
53
  }
54
+ /** Whether deprecated-method warnings are off (client option or PRAXIS_SDK_SILENCE_DEPRECATIONS). */
55
+ silenced = () => this.config.silenceDeprecations === true || envSilencesDeprecations();
52
56
  validate(timeout, retries) {
53
57
  if (!Number.isFinite(timeout) || timeout <= 0)
54
58
  throw new RangeError('timeoutMs must be positive and finite');
55
59
  if (!Number.isSafeInteger(retries) || retries < 0)
56
60
  throw new RangeError('maxRetries must be a non-negative integer');
57
61
  }
58
- scope(options, streaming) {
62
+ scope(operation, options, streaming) {
59
63
  assertKnownOptions(options);
60
64
  const timeoutMs = options.timeoutMs ?? Math.max(this.config.timeoutMs, serverDeadlineMs(options));
61
65
  const maxRetries = options.maxRetries ?? this.config.maxRetries;
@@ -98,7 +102,10 @@ export class Transport {
98
102
  }
99
103
  return {
100
104
  signal,
101
- options: { ...options, headers: Object.fromEntries(headers), client, signal, throwOnError: true, responseStyle: 'fields', ...(streaming ? { parseAs: 'stream' } : {}) },
105
+ // A binary operation is parsed as a Blob whatever the server says in Content-Type: the runtime
106
+ // value must match the declared `Blob | File`, and JSON bytes must survive as bytes.
107
+ options: { ...options, headers: Object.fromEntries(headers), client, signal, throwOnError: true, responseStyle: 'fields',
108
+ ...(streaming ? { parseAs: 'stream' } : isBinaryOperation(operation) ? { parseAs: 'blob' } : {}) },
102
109
  close() { clearTimeout(timer); external?.removeEventListener('abort', abort); },
103
110
  };
104
111
  }
@@ -107,7 +114,7 @@ export class Transport {
107
114
  }
108
115
  /** Internal helper access to response metadata, with the same request policy. */
109
116
  async requestWithResponse(operation, options = {}) {
110
- const scope = this.scope(options, false);
117
+ const scope = this.scope(operation, options, false);
111
118
  try {
112
119
  const result = await abortable(operation(scope.options), scope.signal);
113
120
  return { data: result.data, response: result.response };
@@ -117,7 +124,7 @@ export class Transport {
117
124
  }
118
125
  }
119
126
  async *stream(operation, options = {}) {
120
- const scope = this.scope(options, true);
127
+ const scope = this.scope(operation, options, true);
121
128
  try {
122
129
  const result = await abortable(operation(scope.options), scope.signal);
123
130
  if (!result.response.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase().includes('text/event-stream')) {
@@ -0,0 +1,3 @@
1
+ /** Exported SDK operations whose 2xx response the OpenAPI declares as binary bytes: the core
2
+ * transport resolves them to a Blob whatever the response Content-Type says. */
3
+ export declare const binaryOperations: readonly string[];
@@ -0,0 +1,14 @@
1
+ // Generated by scripts/resources.ts. DO NOT EDIT.
2
+ /** Exported SDK operations whose 2xx response the OpenAPI declares as binary bytes: the core
3
+ * transport resolves them to a Blob whatever the response Content-Type says. */
4
+ export const binaryOperations = [
5
+ 'browserGetSessionFrame',
6
+ 'computersFilesContent',
7
+ 'createAudioSpeech',
8
+ 'downloadVideoContent',
9
+ 'fileRetrieveFileContent',
10
+ 'registryGitFilesRetrieve',
11
+ 'registryPackagesVersionsArchive',
12
+ 'registryPackagesVersionsFilesRetrieve',
13
+ 'skillsVersionsDownload',
14
+ ];