@openmarketsai/order-sheet 0.1.0

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.
Files changed (65) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +183 -0
  4. package/dist/auth.d.ts +24 -0
  5. package/dist/auth.js +36 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/client.d.ts +158 -0
  8. package/dist/client.js +253 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/errors.d.ts +34 -0
  11. package/dist/errors.js +34 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/generated/contract.d.ts +28 -0
  14. package/dist/generated/contract.js +176 -0
  15. package/dist/generated/contract.js.map +1 -0
  16. package/dist/http.d.ts +19 -0
  17. package/dist/http.js +58 -0
  18. package/dist/http.js.map +1 -0
  19. package/dist/index.cjs +1742 -0
  20. package/dist/index.d.ts +41 -0
  21. package/dist/index.js +31 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/math.d.ts +22 -0
  24. package/dist/math.js +55 -0
  25. package/dist/math.js.map +1 -0
  26. package/dist/messages.d.ts +21 -0
  27. package/dist/messages.js +97 -0
  28. package/dist/messages.js.map +1 -0
  29. package/dist/odds.d.ts +12 -0
  30. package/dist/odds.js +33 -0
  31. package/dist/odds.js.map +1 -0
  32. package/dist/quote.d.ts +20 -0
  33. package/dist/quote.js +117 -0
  34. package/dist/quote.js.map +1 -0
  35. package/dist/react.cjs +2137 -0
  36. package/dist/react.d.ts +157 -0
  37. package/dist/react.js +297 -0
  38. package/dist/react.js.map +1 -0
  39. package/dist/sheet.d.ts +77 -0
  40. package/dist/sheet.js +648 -0
  41. package/dist/sheet.js.map +1 -0
  42. package/dist/stream.d.ts +71 -0
  43. package/dist/stream.js +160 -0
  44. package/dist/stream.js.map +1 -0
  45. package/dist/types.d.ts +287 -0
  46. package/dist/types.js +2 -0
  47. package/dist/types.js.map +1 -0
  48. package/dist/ui/styles.css +284 -0
  49. package/dist/ui/theme.d.ts +108 -0
  50. package/dist/ui/theme.js +180 -0
  51. package/dist/ui/theme.js.map +1 -0
  52. package/dist/ui.cjs +2606 -0
  53. package/dist/ui.d.ts +124 -0
  54. package/dist/ui.js +154 -0
  55. package/dist/ui.js.map +1 -0
  56. package/dist/validate.d.ts +20 -0
  57. package/dist/validate.js +126 -0
  58. package/dist/validate.js.map +1 -0
  59. package/dist/venues.d.ts +19 -0
  60. package/dist/venues.js +103 -0
  61. package/dist/venues.js.map +1 -0
  62. package/dist/wire.d.ts +382 -0
  63. package/dist/wire.js +2 -0
  64. package/dist/wire.js.map +1 -0
  65. package/package.json +78 -0
package/dist/client.js ADDED
@@ -0,0 +1,253 @@
1
+ /**
2
+ * The client: one per credential. Caches the account's constraints, loads
3
+ * positions, opens sheets, talks to /preflight, /buy, /cancel and the resting
4
+ * list, and owns the stream. Everything venue-specific arrives from the server.
5
+ */
6
+ import { credentialSupportsStream, resolveCredential } from './auth.js';
7
+ import { OrderSheetError } from './errors.js';
8
+ import { createHttp } from './http.js';
9
+ import { createSheet, newIdempotencyKey } from './sheet.js';
10
+ import { createOrderStream } from './stream.js';
11
+ import { CONSTRAINTS_VERSION } from './generated/contract.js';
12
+ import { fromServerIssue } from './venues.js';
13
+ export const DEFAULT_API_BASE = 'https://api.openmarkets.ai';
14
+ const DEFAULT_LABELS = {
15
+ placePractice: 'Place practice order',
16
+ placeReal: 'Place real order',
17
+ confirmReal: 'Confirm real order',
18
+ placing: 'Placing…',
19
+ practice: 'Practice',
20
+ real: 'Real money',
21
+ };
22
+ /** The API treats an omitted mode as REAL money, so the SDK never sends a leg without one. */
23
+ function assertLegModes(legs) {
24
+ if (!Array.isArray(legs) || legs.length === 0)
25
+ throw new OrderSheetError({ code: 'bad_request', message: 'At least one leg is required.' });
26
+ legs.forEach((l, i) => {
27
+ const mode = l?.mode;
28
+ if (mode !== 'paper' && mode !== 'real') {
29
+ throw new OrderSheetError({ code: 'bad_request', message: `Leg ${i}: mode must be "paper" or "real" (got ${JSON.stringify(mode)}). The API would treat a missing mode as real money.`, details: { index: i, field: 'mode' } });
30
+ }
31
+ });
32
+ }
33
+ export function resolveOptions(input) {
34
+ const auth = input.apiKey
35
+ ? { apiKey: input.apiKey }
36
+ : input.auth
37
+ ? { auth: input.auth }
38
+ : input.getToken
39
+ ? { getToken: input.getToken }
40
+ : {};
41
+ const baseUrl = (input.baseUrl ?? DEFAULT_API_BASE).replace(/\/+$/, '');
42
+ return {
43
+ auth,
44
+ baseUrl,
45
+ streamUrl: input.streamUrl ?? `${baseUrl.replace(/^http/, 'ws')}/flow/v1/stream`,
46
+ actAs: input.actAs ?? null,
47
+ defaults: { mode: 'paper', orderType: 'market', stakeUnit: 'amount', slippage: 0.02, oddsFormat: 'cents', staleAfterMs: 60000, ...(input.defaults ?? {}) },
48
+ realMoney: { enabled: false, confirm: true, ...(input.realMoney ?? {}) },
49
+ preflight: { auto: true, debounceMs: 300, ...(input.preflight ?? {}) },
50
+ constraints: { ttlMs: 60000, ...(input.constraints ?? {}) },
51
+ stream: { enabled: true, pollIntervalMs: 5000, ...(input.stream ?? {}) },
52
+ labels: { ...DEFAULT_LABELS, ...(input.labels ?? {}) },
53
+ now: input.now ?? (() => Date.now()),
54
+ timers: input.timers ?? { set: setTimeout, clear: clearTimeout },
55
+ };
56
+ }
57
+ export function createOrderSheetClient(input) {
58
+ const options = resolveOptions(input);
59
+ const http = createHttp({ baseUrl: options.baseUrl, auth: options.auth, fetch: input.fetch, actAs: options.actAs });
60
+ const handlers = new Map();
61
+ const events = {
62
+ on(event, handler) {
63
+ if (!handlers.has(event))
64
+ handlers.set(event, new Set());
65
+ handlers.get(event).add(handler);
66
+ return () => { handlers.get(event)?.delete(handler); };
67
+ },
68
+ emit(event, payload) {
69
+ for (const h of handlers.get(event) ?? []) {
70
+ try {
71
+ h(payload);
72
+ }
73
+ catch (e) {
74
+ console.error('[order-sheet] handler threw', e);
75
+ }
76
+ }
77
+ },
78
+ };
79
+ let cached = null;
80
+ let inflight = null;
81
+ let stale = false;
82
+ let stream = null;
83
+ const sheets = new Set();
84
+ async function constraints(opts = {}) {
85
+ const fresh = cached && !stale && options.now() - cached.at < options.constraints.ttlMs;
86
+ if (fresh && !opts.force)
87
+ return cached.value;
88
+ if (inflight)
89
+ return inflight;
90
+ inflight = http.request('GET', '/flow/v1/auth/orders/constraints')
91
+ .then((value) => { cached = { value, at: options.now() }; stale = false; events.emit('constraints', value); return value; })
92
+ .finally(() => { inflight = null; });
93
+ return inflight;
94
+ }
95
+ function accountFromConstraints(c) {
96
+ return {
97
+ routerAccountId: c.account.router_account_id,
98
+ environment: c.account.environment,
99
+ canExecute: c.account.can_execute,
100
+ canPractice: c.account.can_practice,
101
+ moneyModes: [...c.account.money_modes],
102
+ practiceOnly: c.account.policy.practice_only,
103
+ isFiduciary: c.account.is_fiduciary,
104
+ issues: c.account.issues.map(fromServerIssue),
105
+ practiceWallet: { partnerId: c.account.practice_wallet.partner_id, currency: c.account.practice_wallet.currency, balance: c.account.practice_wallet.balance },
106
+ policy: { ...c.account.policy },
107
+ constraintsVersion: c.constraints_version,
108
+ };
109
+ }
110
+ async function account(opts = {}) {
111
+ try {
112
+ return accountFromConstraints(await constraints(opts));
113
+ }
114
+ catch (e) {
115
+ // A credential with no bound account cannot read constraints; /auth/me
116
+ // still describes what the credential may do.
117
+ if (e instanceof OrderSheetError && (e.code === 'account_scope_required' || e.code === 'account_not_found')) {
118
+ const me = await http.request('GET', '/flow/v1/auth/me');
119
+ return {
120
+ routerAccountId: me.router_account_id, environment: me.environment, canExecute: me.can_execute, canPractice: me.can_practice,
121
+ moneyModes: [...me.money_modes], practiceOnly: false, isFiduciary: false, issues: [],
122
+ practiceWallet: { partnerId: null, currency: 'ATLAS', balance: null }, policy: null, constraintsVersion: null,
123
+ };
124
+ }
125
+ throw e;
126
+ }
127
+ }
128
+ async function loadPosition(ref) {
129
+ if ('position' in ref)
130
+ return { position: ref.position, partnerId: ref.partnerId ?? null };
131
+ let contestId;
132
+ let positionHash;
133
+ let partnerId;
134
+ if ('liquidityHash' in ref) {
135
+ const parts = ref.liquidityHash.split(':');
136
+ if (parts.length < 7)
137
+ throw new OrderSheetError({ code: 'bad_request', message: `Not a liquidity hash: ${ref.liquidityHash}` });
138
+ partnerId = parts[0];
139
+ positionHash = parts.slice(1).join(':');
140
+ contestId = parts[1];
141
+ }
142
+ else {
143
+ const parts = ref.positionHash.split(':');
144
+ if (parts.length < 6)
145
+ throw new OrderSheetError({ code: 'bad_request', message: `Not a position hash: ${ref.positionHash}` });
146
+ positionHash = ref.positionHash;
147
+ contestId = parts[0];
148
+ partnerId = ref.partnerId ?? null;
149
+ }
150
+ const positions = await http.request('GET', `/flow/v1/contests/${encodeURIComponent(contestId)}/liquidity`);
151
+ const position = positions.find((p) => p.position_hash === positionHash);
152
+ if (!position)
153
+ throw new OrderSheetError({ code: 'position_not_found', message: `Position ${positionHash} is not quoted on contest ${contestId}.`, status: 404 });
154
+ return { position, partnerId };
155
+ }
156
+ function withAtomic(body, atomic, verifyLiquidity) {
157
+ if (atomic)
158
+ return { ...body, check_all_first: true, on_leg_failure: 'halt', placement: 'parallel', verify_liquidity: true };
159
+ return verifyLiquidity ? { ...body, verify_liquidity: true } : body;
160
+ }
161
+ async function ensureStream() {
162
+ if (!options.stream.enabled || !credentialSupportsStream(options.auth))
163
+ return null;
164
+ if (!stream) {
165
+ stream = createOrderStream({
166
+ url: options.streamUrl,
167
+ getApiKey: async () => (await resolveCredential(options.auth)).value,
168
+ WebSocket: input.WebSocket,
169
+ timers: options.timers,
170
+ });
171
+ stream.on('order.update', (f) => events.emit('order.update', f));
172
+ stream.on('order.settled', (f) => events.emit('order.settled', f));
173
+ stream.on('balance.update', (f) => {
174
+ stale = true;
175
+ events.emit('balance.update', f);
176
+ events.emit('constraints', cached?.value ?? null);
177
+ // Balances feed the local checks: with a sheet open, actually re-read
178
+ // them (single-flighted); otherwise the next constraints() call does.
179
+ if (sheets.size > 0)
180
+ constraints().catch(() => { });
181
+ });
182
+ stream.on('connected', (f) => events.emit('stream.connected', f));
183
+ }
184
+ await stream.connect();
185
+ return stream;
186
+ }
187
+ const client = {
188
+ options,
189
+ http,
190
+ events,
191
+ account,
192
+ constraints,
193
+ getCachedConstraints: () => cached?.value ?? null,
194
+ constraintsStale: () => !!cached && cached.value.constraints_version !== CONSTRAINTS_VERSION,
195
+ accountFromConstraints,
196
+ invalidateConstraints() { stale = true; events.emit('constraints', cached?.value ?? null); },
197
+ loadPosition,
198
+ openSheet(ref, init) {
199
+ const created = createSheet(client, ref, init);
200
+ const sheet = { ...created, destroy() { sheets.delete(sheet); created.destroy(); } };
201
+ sheets.add(sheet);
202
+ return sheet;
203
+ },
204
+ async preflight(legs, opts = {}) {
205
+ assertLegModes(legs);
206
+ return http.request('POST', '/flow/v1/auth/orders/preflight', { body: withAtomic({ orders: legs }, opts.atomic, opts.verifyLiquidity) });
207
+ },
208
+ async buy(legs, opts = {}) {
209
+ assertLegModes(legs);
210
+ if (!options.realMoney.enabled && legs.some((l) => l.mode === 'real')) {
211
+ throw new OrderSheetError({ code: 'real_money_disabled', message: 'A leg has mode "real" but real-money orders are turned off in this app (realMoney.enabled is false).' });
212
+ }
213
+ const body = withAtomic({
214
+ orders: legs,
215
+ ...(opts.opportunityId ? { opportunity_id: opts.opportunityId } : {}),
216
+ ...(opts.modelId ? { model_id: opts.modelId } : {}),
217
+ }, opts.atomic, opts.verifyLiquidity);
218
+ const key = opts.idempotencyKey ?? newIdempotencyKey();
219
+ return http.request('POST', '/flow/v1/auth/orders/buy', { body, headers: { 'Idempotency-Key': key } });
220
+ },
221
+ async restingOrders() {
222
+ return (await http.request('GET', '/flow/v1/auth/orders/resting/me')).orders;
223
+ },
224
+ listOrders(opts = {}) {
225
+ const q = new URLSearchParams();
226
+ if (opts.contestId)
227
+ q.set('contest_id', opts.contestId);
228
+ if (opts.status)
229
+ q.set('status', opts.status);
230
+ q.set('limit', String(opts.limit ?? 50));
231
+ return http.request('GET', `/flow/v1/auth/orders?${q.toString()}`);
232
+ },
233
+ cancelOrders(routerOrderIds) {
234
+ return http.request('POST', '/flow/v1/auth/orders/cancel', { body: { router_order_ids: routerOrderIds } });
235
+ },
236
+ me: () => http.request('GET', '/flow/v1/auth/me'),
237
+ get stream() { return stream; },
238
+ ensureStream,
239
+ reset() {
240
+ cached = null;
241
+ stale = false;
242
+ stream?.disconnect();
243
+ stream = null;
244
+ for (const s of sheets)
245
+ s.destroy();
246
+ sheets.clear();
247
+ events.emit('constraints', null);
248
+ },
249
+ destroy() { client.reset(); handlers.clear(); },
250
+ };
251
+ return client;
252
+ }
253
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAoB,MAAM,WAAW,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,UAAU,EAA6B,MAAM,WAAW,CAAA;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAA8B,MAAM,YAAY,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAwC,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAM7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAuG5D,MAAM,cAAc,GAAqB;IACrC,aAAa,EAAE,sBAAsB;IACrC,SAAS,EAAE,kBAAkB;IAC7B,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,YAAY;CACrB,CAAA;AAED,8FAA8F;AAC9F,SAAS,cAAc,CAAC,IAAc;IAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,C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,CAAA;QAC9H,CAAC;QACD,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAK,KAAK,EAAE,kBAAkB,CAAC;QACrD,IAAI,MAAM,KAAK,OAAO,MAAM,CAAA,CAAC,CAAC;QAC9B,YAAY;QACZ,KAAK;YACD,MAAM,GAAG,IAAI,CAAC;YAAC,KAAK,GAAG,KAAK,CAAA;YAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;YAAC,MAAM,GAAG,IAAI,CAAA;YACnC,KAAK,MAAM,CAAC,IAAI,MAAM;gBAAE,CAAC,CAAC,OAAO,EAAE,CAAA;YACnC,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA,CAAC,CAAC;KACjD,CAAA;IACD,OAAO,MAAM,CAAA;AACjB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type RequestErrorCode } from './generated/contract.js';
2
+ /**
3
+ * SDK-side failure codes, beside the API's own request error codes. A request
4
+ * error means the REQUEST was wrong or refused (4xx/5xx, network); a declined
5
+ * LEG inside a 200 is never thrown — it is an `Issue` on the result.
6
+ */
7
+ export type ClientErrorCode = 'network_error' | 'invalid_response' | 'not_configured' | 'no_credential' | 'position_not_found' | 'stream_unavailable'
8
+ /** A raw `buy()` carried a real leg while `realMoney.enabled` is false. */
9
+ | 'real_money_disabled';
10
+ export type OrderSheetErrorCode = RequestErrorCode | ClientErrorCode | (string & {});
11
+ export declare class OrderSheetError extends Error {
12
+ readonly code: OrderSheetErrorCode;
13
+ /** HTTP status, or null for a client-side failure. */
14
+ readonly status: number | null;
15
+ /** The API's `error.details`, when it sent any. */
16
+ readonly details: Record<string, unknown> | null;
17
+ /** A retry may succeed (network, 5xx, 429). Never true for a 4xx that describes the request. */
18
+ readonly retryable: boolean;
19
+ constructor(init: {
20
+ code: OrderSheetErrorCode;
21
+ message: string;
22
+ status?: number | null;
23
+ details?: Record<string, unknown> | null;
24
+ retryable?: boolean;
25
+ cause?: unknown;
26
+ });
27
+ }
28
+ export declare function isOrderSheetError(e: unknown): e is OrderSheetError;
29
+ /**
30
+ * What to show an END USER for a thrown error. `error.message` is the API's
31
+ * developer-facing reason; this is the server-authored plain-language line for
32
+ * the request-error code (generated), or a status-based fallback.
33
+ */
34
+ export declare function userMessageFor(e: OrderSheetError): string;
package/dist/errors.js ADDED
@@ -0,0 +1,34 @@
1
+ import { REQUEST_ERROR_MESSAGES } from './generated/contract.js';
2
+ export class OrderSheetError extends Error {
3
+ constructor(init) {
4
+ super(init.message);
5
+ this.name = 'OrderSheetError';
6
+ this.code = init.code;
7
+ this.status = init.status ?? null;
8
+ this.details = init.details ?? null;
9
+ this.retryable = init.retryable ?? false;
10
+ if (init.cause !== undefined)
11
+ this.cause = init.cause;
12
+ }
13
+ }
14
+ export function isOrderSheetError(e) {
15
+ return e instanceof OrderSheetError || (typeof e === 'object' && e !== null && e.name === 'OrderSheetError');
16
+ }
17
+ /**
18
+ * What to show an END USER for a thrown error. `error.message` is the API's
19
+ * developer-facing reason; this is the server-authored plain-language line for
20
+ * the request-error code (generated), or a status-based fallback.
21
+ */
22
+ export function userMessageFor(e) {
23
+ const known = REQUEST_ERROR_MESSAGES[e.code];
24
+ if (known)
25
+ return known;
26
+ if (e.code === 'real_money_disabled')
27
+ return 'Real-money orders are turned off in this app.';
28
+ if (e.code === 'network_error' || e.status === null)
29
+ return 'Couldn\'t reach OpenMarkets. Check your connection and try again.';
30
+ if (e.retryable)
31
+ return 'Something went wrong on our side. Try again.';
32
+ return 'This order couldn\'t be submitted.';
33
+ }
34
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAyB,MA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source: src/types/objects/order-constraints.ts (the server contract)
5
+ * Generator: npm run gen:order-sheet-contract
6
+ * CI guard: npm run gen:order-sheet-contract:check
7
+ *
8
+ * Every value here is a closed union the OpenMarkets API emits. Adding a
9
+ * server code regenerates this file, and the SDK's exhaustive message table
10
+ * (src/messages.ts) then fails to compile until the new code has a message.
11
+ */
12
+ /** The shape version of GET /flow/v1/auth/orders/constraints this SDK was generated against. */
13
+ export declare const CONSTRAINTS_VERSION = "2026-09-29.1";
14
+ /** Per-leg issue codes: `rejected_code` on /buy and /preflight, and every reason on /constraints. */
15
+ export declare const ISSUE_CODES: readonly ["real_money_not_permitted", "practice_not_permitted", "test_mode_requires_paper", "venue_disabled", "orders_not_supported", "scope_not_granted", "execution_limit_exceeded", "insufficient_balance", "venue_shard_underfunded", "below_min_order", "above_max_order", "unfillable", "below_min_contracts", "amount_off_increment", "price_out_of_band", "above_max_price", "price_off_tick", "insufficient_size", "insufficient_live_depth", "no_viable_venues", "no_live_price_for_paper", "invalid_requested_amount", "halted_upstream", "unknown"];
16
+ export type IssueCode = (typeof ISSUE_CODES)[number];
17
+ /** What a user can do about an issue. */
18
+ export declare const ISSUE_FIXES: readonly ["raise_price", "lower_price", "raise_stake", "lower_stake", "round_stake", "connect_venue", "fund_venue", "switch_venue", "switch_to_paper", "switch_to_real", "use_market", "use_limit", "grant_scope", "upgrade_plan", "retry", "none"];
19
+ export type IssueFix = (typeof ISSUE_FIXES)[number];
20
+ /** Envelope error codes the /buy and /preflight REQUEST can fail with (4xx/5xx) — the handler's and the middleware's in front of it. */
21
+ export declare const REQUEST_ERROR_CODES: readonly ["missing_credentials", "invalid_api_key", "invalid_jwt", "auth_error", "not_authenticated", "rate_limit_exceeded", "account_forbidden", "scope_not_granted", "idempotency_error", "account_scope_required", "account_not_found", "environment_unresolved", "execution_key_required", "entitlement_required", "bad_request", "unknown_parameter", "conflicting_parameters", "unsupported_order_type", "test_mode_requires_paper", "real_money_not_permitted", "connect_scope_required", "model_not_found", "model_archived", "opportunity_not_found", "currency_mismatch", "model_mismatch", "idempotency_conflict", "internal_error"];
22
+ export type RequestErrorCode = (typeof REQUEST_ERROR_CODES)[number];
23
+ /** What an end user reads when the REQUEST failed (the error's own `message` is developer-facing). */
24
+ export declare const REQUEST_ERROR_MESSAGES: Record<RequestErrorCode, string>;
25
+ /** The server's default severity per code — the SDK's fallback when a response carries no issue object. */
26
+ export declare const ISSUE_SEVERITY: Record<IssueCode, 'block' | 'warn' | 'info'>;
27
+ /** The server's default fix per code (context-dependent codes carry their most common fix). */
28
+ export declare const ISSUE_DEFAULT_FIX: Record<IssueCode, IssueFix>;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * GENERATED — do not edit.
3
+ *
4
+ * Source: src/types/objects/order-constraints.ts (the server contract)
5
+ * Generator: npm run gen:order-sheet-contract
6
+ * CI guard: npm run gen:order-sheet-contract:check
7
+ *
8
+ * Every value here is a closed union the OpenMarkets API emits. Adding a
9
+ * server code regenerates this file, and the SDK's exhaustive message table
10
+ * (src/messages.ts) then fails to compile until the new code has a message.
11
+ */
12
+ /** The shape version of GET /flow/v1/auth/orders/constraints this SDK was generated against. */
13
+ export const CONSTRAINTS_VERSION = '2026-09-29.1';
14
+ /** Per-leg issue codes: `rejected_code` on /buy and /preflight, and every reason on /constraints. */
15
+ export const ISSUE_CODES = [
16
+ 'real_money_not_permitted',
17
+ 'practice_not_permitted',
18
+ 'test_mode_requires_paper',
19
+ 'venue_disabled',
20
+ 'orders_not_supported',
21
+ 'scope_not_granted',
22
+ 'execution_limit_exceeded',
23
+ 'insufficient_balance',
24
+ 'venue_shard_underfunded',
25
+ 'below_min_order',
26
+ 'above_max_order',
27
+ 'unfillable',
28
+ 'below_min_contracts',
29
+ 'amount_off_increment',
30
+ 'price_out_of_band',
31
+ 'above_max_price',
32
+ 'price_off_tick',
33
+ 'insufficient_size',
34
+ 'insufficient_live_depth',
35
+ 'no_viable_venues',
36
+ 'no_live_price_for_paper',
37
+ 'invalid_requested_amount',
38
+ 'halted_upstream',
39
+ 'unknown',
40
+ ];
41
+ /** What a user can do about an issue. */
42
+ export const ISSUE_FIXES = [
43
+ 'raise_price',
44
+ 'lower_price',
45
+ 'raise_stake',
46
+ 'lower_stake',
47
+ 'round_stake',
48
+ 'connect_venue',
49
+ 'fund_venue',
50
+ 'switch_venue',
51
+ 'switch_to_paper',
52
+ 'switch_to_real',
53
+ 'use_market',
54
+ 'use_limit',
55
+ 'grant_scope',
56
+ 'upgrade_plan',
57
+ 'retry',
58
+ 'none',
59
+ ];
60
+ /** Envelope error codes the /buy and /preflight REQUEST can fail with (4xx/5xx) — the handler's and the middleware's in front of it. */
61
+ export const REQUEST_ERROR_CODES = [
62
+ 'missing_credentials',
63
+ 'invalid_api_key',
64
+ 'invalid_jwt',
65
+ 'auth_error',
66
+ 'not_authenticated',
67
+ 'rate_limit_exceeded',
68
+ 'account_forbidden',
69
+ 'scope_not_granted',
70
+ 'idempotency_error',
71
+ 'account_scope_required',
72
+ 'account_not_found',
73
+ 'environment_unresolved',
74
+ 'execution_key_required',
75
+ 'entitlement_required',
76
+ 'bad_request',
77
+ 'unknown_parameter',
78
+ 'conflicting_parameters',
79
+ 'unsupported_order_type',
80
+ 'test_mode_requires_paper',
81
+ 'real_money_not_permitted',
82
+ 'connect_scope_required',
83
+ 'model_not_found',
84
+ 'model_archived',
85
+ 'opportunity_not_found',
86
+ 'currency_mismatch',
87
+ 'model_mismatch',
88
+ 'idempotency_conflict',
89
+ 'internal_error',
90
+ ];
91
+ /** What an end user reads when the REQUEST failed (the error's own `message` is developer-facing). */
92
+ export const REQUEST_ERROR_MESSAGES = {
93
+ missing_credentials: "Sign in to place orders.",
94
+ invalid_api_key: "This app's access key isn't valid any more.",
95
+ invalid_jwt: "Your session has expired — sign in again.",
96
+ auth_error: "We couldn't check your sign-in. Try again.",
97
+ not_authenticated: "Sign in to place orders.",
98
+ rate_limit_exceeded: "Too many requests — wait a moment and try again.",
99
+ account_forbidden: "This app can't act for that account.",
100
+ scope_not_granted: "This app hasn't been allowed to place orders.",
101
+ idempotency_error: "The order couldn't be submitted safely. Try again.",
102
+ account_scope_required: "This sign-in isn't linked to a trading account.",
103
+ account_not_found: "That trading account no longer exists.",
104
+ environment_unresolved: "We couldn't tell whether this is a test or live key.",
105
+ execution_key_required: "This app's key can read markets but not trade.",
106
+ entitlement_required: "Trading isn't included in this plan.",
107
+ bad_request: "Something in this order wasn't valid.",
108
+ unknown_parameter: "Something in this order wasn't valid.",
109
+ conflicting_parameters: "Something in this order wasn't valid.",
110
+ unsupported_order_type: "That venue doesn't take this type of order.",
111
+ test_mode_requires_paper: "This is a test key — it can only place practice orders.",
112
+ real_money_not_permitted: "Real-money trading is not included in this plan.",
113
+ connect_scope_required: "This account hasn't allowed this app to trade.",
114
+ model_not_found: "That model doesn't exist.",
115
+ model_archived: "That model is archived and takes no new orders.",
116
+ opportunity_not_found: "That order group doesn't exist.",
117
+ currency_mismatch: "Those orders use different currencies.",
118
+ model_mismatch: "That order group belongs to a different model.",
119
+ idempotency_conflict: "This order was already submitted with different details.",
120
+ internal_error: "Something went wrong on our side. Try again.",
121
+ };
122
+ /** The server's default severity per code — the SDK's fallback when a response carries no issue object. */
123
+ export const ISSUE_SEVERITY = {
124
+ real_money_not_permitted: 'block',
125
+ practice_not_permitted: 'block',
126
+ test_mode_requires_paper: 'block',
127
+ venue_disabled: 'block',
128
+ orders_not_supported: 'block',
129
+ scope_not_granted: 'block',
130
+ execution_limit_exceeded: 'block',
131
+ insufficient_balance: 'block',
132
+ venue_shard_underfunded: 'block',
133
+ below_min_order: 'block',
134
+ above_max_order: 'block',
135
+ unfillable: 'block',
136
+ below_min_contracts: 'block',
137
+ amount_off_increment: 'warn',
138
+ price_out_of_band: 'block',
139
+ above_max_price: 'block',
140
+ price_off_tick: 'warn',
141
+ insufficient_size: 'block',
142
+ insufficient_live_depth: 'block',
143
+ no_viable_venues: 'block',
144
+ no_live_price_for_paper: 'block',
145
+ invalid_requested_amount: 'block',
146
+ halted_upstream: 'info',
147
+ unknown: 'block',
148
+ };
149
+ /** The server's default fix per code (context-dependent codes carry their most common fix). */
150
+ export const ISSUE_DEFAULT_FIX = {
151
+ real_money_not_permitted: 'upgrade_plan',
152
+ practice_not_permitted: 'none',
153
+ test_mode_requires_paper: 'switch_to_paper',
154
+ venue_disabled: 'connect_venue',
155
+ orders_not_supported: 'switch_venue',
156
+ scope_not_granted: 'grant_scope',
157
+ execution_limit_exceeded: 'none',
158
+ insufficient_balance: 'fund_venue',
159
+ venue_shard_underfunded: 'fund_venue',
160
+ below_min_order: 'raise_stake',
161
+ above_max_order: 'lower_stake',
162
+ unfillable: 'raise_stake',
163
+ below_min_contracts: 'raise_stake',
164
+ amount_off_increment: 'round_stake',
165
+ price_out_of_band: 'lower_price',
166
+ above_max_price: 'raise_price',
167
+ price_off_tick: 'none',
168
+ insufficient_size: 'lower_stake',
169
+ insufficient_live_depth: 'switch_venue',
170
+ no_viable_venues: 'switch_venue',
171
+ no_live_price_for_paper: 'switch_venue',
172
+ invalid_requested_amount: 'raise_stake',
173
+ halted_upstream: 'none',
174
+ unknown: 'retry',
175
+ };
176
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,gGAAgG;AAChG,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAA;AAEjD,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,0BAA0B;IAC1B,wBAAwB;IACxB,0BAA0B;IAC1B,gBAAgB;IAChB,sBAAsB;IACtB,mBAAmB;IACnB,0BAA0B;IAC1B,sBAAsB;IACtB,yBAAyB;IACzB,iBAAiB;IACjB,iBAAiB;IACjB,YAAY;IACZ,qBAAqB;IACrB,sBAAsB;IACtB,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,yBAAyB;IACzB,kBA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AE,iBAAiB;IAC3C,cAAc,EAAE,eAAe;IAC/B,oBAAoB,EAAE,cAAc;IACpC,iBAAiB,EAAE,aAAa;IAChC,wBAAwB,EAAE,MAAM;IAChC,oBAAoB,EAAE,YAAY;IAClC,uBAAuB,EAAE,YAAY;IACrC,eAAe,EAAE,aAAa;IAC9B,eAAe,EAAE,aAAa;IAC9B,UAAU,EAAE,aAAa;IACzB,mBAAmB,EAAE,aAAa;IAClC,oBAAoB,EAAE,aAAa;IACnC,iBAAiB,EAAE,aAAa;IAChC,eAAe,EAAE,aAAa;IAC9B,cAAc,EAAE,MAAM;IACtB,iBAAiB,EAAE,aAAa;IAChC,uBAAuB,EAAE,cAAc;IACvC,gBAAgB,EAAE,cAAc;IAChC,uBAAuB,EAAE,cAAc;IACvC,wBAAwB,EAAE,aAAa;IACvC,eAAe,EAAE,MAAM;IACvB,OAAO,EAAE,OAAO;CACnB,CAAA"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { type AuthOptions } from './auth.js';
2
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
3
+ export interface HttpOptions {
4
+ baseUrl: string;
5
+ auth: AuthOptions;
6
+ fetch?: FetchLike;
7
+ /** X-OpenMarkets-Account — act for a Connect end user (needs connect:trade on the key). */
8
+ actAs?: string | null;
9
+ }
10
+ export interface RequestOptions {
11
+ body?: unknown;
12
+ headers?: Record<string, string>;
13
+ signal?: AbortSignal;
14
+ }
15
+ export interface Http {
16
+ request<T>(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, opts?: RequestOptions): Promise<T>;
17
+ baseUrl: string;
18
+ }
19
+ export declare function createHttp(options: HttpOptions): Http;
package/dist/http.js ADDED
@@ -0,0 +1,58 @@
1
+ import { OrderSheetError } from './errors.js';
2
+ import { resolveCredential } from './auth.js';
3
+ const RETRYABLE_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);
4
+ export function createHttp(options) {
5
+ const baseUrl = options.baseUrl.replace(/\/+$/, '');
6
+ const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
7
+ async function request(method, path, opts = {}) {
8
+ const cred = await resolveCredential(options.auth);
9
+ const headers = {
10
+ Accept: 'application/json',
11
+ ...cred.headers,
12
+ ...(options.actAs ? { 'X-OpenMarkets-Account': options.actAs } : {}),
13
+ ...(opts.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
14
+ ...(opts.headers ?? {}),
15
+ };
16
+ let res;
17
+ try {
18
+ res = await doFetch(`${baseUrl}${path}`, {
19
+ method,
20
+ headers,
21
+ body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
22
+ signal: opts.signal,
23
+ });
24
+ }
25
+ catch (cause) {
26
+ if (cause?.name === 'AbortError')
27
+ throw cause;
28
+ throw new OrderSheetError({ code: 'network_error', message: `Could not reach ${baseUrl}: ${cause?.message ?? String(cause)}`, retryable: true, cause });
29
+ }
30
+ let parsed = null;
31
+ const text = await res.text();
32
+ if (text) {
33
+ try {
34
+ parsed = JSON.parse(text);
35
+ }
36
+ catch {
37
+ throw new OrderSheetError({ code: 'invalid_response', message: `Non-JSON response (${res.status}) from ${method} ${path}`, status: res.status, retryable: res.status >= 500 });
38
+ }
39
+ }
40
+ if (!res.ok) {
41
+ const err = parsed?.error;
42
+ throw new OrderSheetError({
43
+ code: err?.code ?? `http_${res.status}`,
44
+ message: err?.message ?? `${method} ${path} failed with ${res.status}`,
45
+ status: res.status,
46
+ details: err?.details ?? null,
47
+ retryable: RETRYABLE_STATUS.has(res.status),
48
+ });
49
+ }
50
+ const env = parsed;
51
+ if (!env || typeof env !== 'object' || !('data' in env)) {
52
+ throw new OrderSheetError({ code: 'invalid_response', message: `Unexpected response shape from ${method} ${path}`, status: res.status });
53
+ }
54
+ return env.data;
55
+ }
56
+ return { request, baseUrl };
57
+ }
58
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA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