@0xmonaco/types 0.8.7-develop.34bd452 → 0.8.7-develop.ab57a24

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 (47) hide show
  1. package/dist/api/index.d.ts +7 -0
  2. package/dist/applications/index.d.ts +47 -5
  3. package/dist/applications/index.js +2 -1
  4. package/dist/applications/requests.d.ts +78 -0
  5. package/dist/applications/requests.js +7 -0
  6. package/dist/applications/responses.d.ts +211 -1
  7. package/dist/applications/responses.js +3 -1
  8. package/dist/auth/index.d.ts +6 -12
  9. package/dist/auth/index.js +2 -2
  10. package/dist/auth/responses.d.ts +0 -11
  11. package/dist/delegated-agents/index.d.ts +17 -1
  12. package/dist/faucet/index.d.ts +54 -0
  13. package/dist/faucet/index.js +10 -0
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.js +4 -0
  16. package/dist/margin-accounts/index.d.ts +10 -3
  17. package/dist/market/index.d.ts +83 -0
  18. package/dist/positions/index.d.ts +1 -0
  19. package/dist/profile/index.d.ts +88 -1
  20. package/dist/sdk/index.d.ts +12 -0
  21. package/dist/sub-accounts/index.d.ts +145 -0
  22. package/dist/sub-accounts/index.js +9 -0
  23. package/dist/trading/index.d.ts +4 -0
  24. package/dist/trading/responses.d.ts +8 -2
  25. package/dist/validation/margin-accounts.d.ts +6 -1
  26. package/dist/validation/margin-accounts.js +11 -1
  27. package/dist/validation/profile.d.ts +7 -0
  28. package/dist/validation/profile.js +7 -0
  29. package/dist/validation/trading.d.ts +8 -0
  30. package/dist/validation/trading.js +42 -0
  31. package/dist/whitelist/index.d.ts +44 -0
  32. package/dist/whitelist/index.js +10 -0
  33. package/dist/wire/assert.d.ts +54 -0
  34. package/dist/wire/assert.js +0 -0
  35. package/dist/wire/audit.d.ts +47 -0
  36. package/dist/wire/audit.js +43 -0
  37. package/dist/wire/coverage.d.ts +1 -0
  38. package/dist/wire/coverage.js +0 -0
  39. package/dist/wire/index.d.ts +21 -0
  40. package/dist/wire/index.js +2 -0
  41. package/dist/wire/operations.d.ts +15 -0
  42. package/dist/wire/operations.js +95 -0
  43. package/dist/wire/schema.d.ts +8432 -0
  44. package/dist/wire/schema.js +4 -0
  45. package/dist/withdrawals/index.d.ts +43 -0
  46. package/dist/withdrawals/index.js +0 -0
  47. package/package.json +6 -2
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
11
+ import type { BaseAPI } from "../api";
12
+ /** Body for a whitelist application. */
13
+ export interface SubmitWhitelistRequest {
14
+ /** Applicant wallet address (0x-prefixed, 40 hex chars) */
15
+ wallet_address: string;
16
+ /** Applicant email address */
17
+ email: string;
18
+ /** Applicant Twitter/X username (1-15 chars) */
19
+ twitter_username?: string;
20
+ /** Applicant Telegram username (5-32 chars) */
21
+ telegram_username?: string;
22
+ }
23
+ /** Response to a whitelist application. */
24
+ export interface SubmitWhitelistResponse {
25
+ /** Human-readable status message */
26
+ message: string;
27
+ /** Created user UUID (pending approval) */
28
+ user_id: string | null;
29
+ }
30
+ /**
31
+ * Whitelist API interface. The submit endpoint is public (no auth required).
32
+ */
33
+ export interface WhitelistAPI extends BaseAPI {
34
+ /**
35
+ * Submits a whitelist (waitlist) application.
36
+ *
37
+ * Public/unauthenticated. The server validates and de-duplicates by wallet
38
+ * address and email, creating an inactive user pending approval.
39
+ *
40
+ * @param body - Applicant details
41
+ * @returns Promise resolving to the status message and created user id
42
+ */
43
+ submit(body: SubmitWhitelistRequest): Promise<SubmitWhitelistResponse>;
44
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Compile-time helpers that tie the hand-written ergonomic SDK types to the
3
+ * generated wire schema in `./schema.ts`.
4
+ *
5
+ * Everything here lives purely at the type level — there is no runtime output —
6
+ * so a field the OpenAPI spec gains but an ergonomic type forgot to declare
7
+ * becomes a `tsc` error. This is the type-checking half of the MON-1476 drift
8
+ * tripwire (the other half is the CI fail-on-diff check on the generated
9
+ * `schema.ts`). See `./README.md` for how to register a new type.
10
+ */
11
+ import type { components } from "./schema";
12
+ /** All schema component types generated from the OpenAPI spec. */
13
+ export type WireSchemas = components["schemas"];
14
+ /** A single generated wire schema, addressed by its OpenAPI component name. */
15
+ export type WireSchema<K extends keyof WireSchemas> = WireSchemas[K];
16
+ /** Strip every `_` from a string-literal type: `a_b_c` -> `abc`. */
17
+ type StripUnderscores<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${StripUnderscores<Tail>}` : S;
18
+ /**
19
+ * Canonical form of a field name: lower-cased and underscore-free, so that
20
+ * snake_case (`available_balance`) and camelCase (`availableBalance`) names
21
+ * collapse to the same key. This lets the coverage check ignore the casing
22
+ * convention a given ergonomic domain happens to use.
23
+ *
24
+ * Caveat: names that differ only by case (e.g. `T` vs `t`) collapse together —
25
+ * do not register types that rely on such a distinction.
26
+ */
27
+ type CanonicalKey<S extends string> = Lowercase<StripUnderscores<S>>;
28
+ /** Re-key an object type by the canonical form of each of its string keys. */
29
+ type CanonicalKeys<T> = {
30
+ [K in keyof T as K extends string ? CanonicalKey<K> : never]: true;
31
+ };
32
+ /** Canonical wire field names that the ergonomic type `Ergo` does not declare. */
33
+ export type MissingWireFields<Ergo, Wire> = Exclude<keyof CanonicalKeys<Wire>, keyof CanonicalKeys<Ergo>>;
34
+ /**
35
+ * Resolves to `true` when `Ergo` declares every field the wire schema `Wire`
36
+ * has (comparing canonical names, so casing/underscore style is irrelevant and
37
+ * ergonomic enrichments — extra fields, bigint/branded value types — are
38
+ * allowed). Otherwise resolves to an error object naming the missing fields, so
39
+ * a failing {@link Expect} points straight at the drift.
40
+ */
41
+ export type WireCovered<Ergo, Wire> = [MissingWireFields<Ergo, Wire>] extends [never] ? true : {
42
+ __MISSING_WIRE_FIELDS__: MissingWireFields<Ergo, Wire>;
43
+ };
44
+ /**
45
+ * Assertion sink. `Expect<WireCovered<Ergo, Wire>>` is a type alias that only
46
+ * type-checks when its argument is exactly `true`, emitting no runtime code:
47
+ *
48
+ * type _Balance = Expect<WireCovered<AccountBalance, WireSchema<"AccountBalance">>>;
49
+ *
50
+ * If `WireCovered` resolves to the error object, `T extends true` fails and
51
+ * `tsc` reports the missing wire fields at this line.
52
+ */
53
+ export type Expect<T extends true> = T;
54
+ export {};
File without changes
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { type OperationId } from "./operations";
22
+ import type { operations } from "./schema";
23
+ /** A surface's coverage registries (the two maps exported by its `coverage.ts`). */
24
+ export interface SurfaceClassification {
25
+ /** operationId → the SDK symbol (method/hook/tool) that covers it. */
26
+ covered: Partial<Record<keyof operations, string>>;
27
+ /** operationId → the reason it is intentionally not covered. */
28
+ excluded: Partial<Record<keyof operations, string>>;
29
+ }
30
+ /** Result of auditing one surface's classification against the spec. */
31
+ export interface CoverageAudit {
32
+ /** operationIds in the spec that appear in neither `covered` nor `excluded`. */
33
+ unclassified: OperationId[];
34
+ /** operationIds listed in BOTH `covered` and `excluded`. */
35
+ duplicated: string[];
36
+ /** Registry keys that are not (or no longer) real operationIds. */
37
+ unknown: string[];
38
+ /** True when the surface classifies every operationId exactly once. */
39
+ ok: boolean;
40
+ }
41
+ /**
42
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
43
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
44
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
45
+ * exercise synthetic op sets.
46
+ */
47
+ export declare function auditSurface(classification: SurfaceClassification, operationIds?: readonly string[]): CoverageAudit;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { OPERATION_IDS } from "./operations";
22
+ /**
23
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
24
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
25
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
26
+ * exercise synthetic op sets.
27
+ */
28
+ export function auditSurface(classification, operationIds = OPERATION_IDS) {
29
+ const covered = Object.keys(classification.covered);
30
+ const excluded = Object.keys(classification.excluded);
31
+ const all = new Set(operationIds);
32
+ const classified = new Set([...covered, ...excluded]);
33
+ const excludedSet = new Set(excluded);
34
+ const unclassified = operationIds.filter((op) => !classified.has(op));
35
+ const duplicated = covered.filter((op) => excludedSet.has(op)).sort();
36
+ const unknown = [...new Set([...covered, ...excluded].filter((op) => !all.has(op)))].sort();
37
+ return {
38
+ unclassified: unclassified,
39
+ duplicated,
40
+ unknown,
41
+ ok: unclassified.length === 0 && duplicated.length === 0 && unknown.length === 0,
42
+ };
43
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Generated wire-types layer (MON-1476 drift tripwire).
3
+ *
4
+ * `schema.ts` is generated from `docs/src/proto-openapi/api/openapi.yaml` by
5
+ * `make ts-wire-gen` — do not edit it by hand. This barrel re-exports the
6
+ * generated `paths` / `components` / `operations` interfaces plus the
7
+ * {@link WireSchema} / {@link WireCovered} helpers the ergonomic types use to
8
+ * stay in sync with the spec.
9
+ *
10
+ * Consumers import the raw spec types from the `@0xmonaco/types/wire` subpath;
11
+ * the ergonomic types in the rest of the package are the supported surface.
12
+ *
13
+ * It also exports the generated runtime `OPERATION_IDS` list and the
14
+ * `auditSurface` helper that power the MON-1489 endpoint-coverage gate.
15
+ */
16
+ export type { Expect, MissingWireFields, WireCovered, WireSchema, WireSchemas } from "./assert";
17
+ export type { CoverageAudit, SurfaceClassification } from "./audit";
18
+ export { auditSurface } from "./audit";
19
+ export type { OperationId } from "./operations";
20
+ export { OPERATION_IDS } from "./operations";
21
+ export type { components, operations, paths } from "./schema";
@@ -0,0 +1,2 @@
1
+ export { auditSurface } from "./audit";
2
+ export { OPERATION_IDS } from "./operations";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * GENERATED — DO NOT EDIT BY HAND.
3
+ *
4
+ * Runtime list of every OpenAPI operationId in the canonical spec
5
+ * (docs/src/proto-openapi/api/openapi.yaml), emitted by `make ts-wire-gen`
6
+ * (scripts/gen-operation-ids.ts) alongside the type-only `schema.ts`.
7
+ *
8
+ * The MON-1489 endpoint-coverage gate iterates this list to assert that every
9
+ * operationId is classified (covered or intentionally excluded) on each
10
+ * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
+ * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
+ */
13
+ export declare const OPERATION_IDS: readonly ["add_position_margin", "attach_position_tp_sl", "authenticate_backend", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "close_position", "create_challenge", "create_conditional_order", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "ensure_parent_margin_account", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_chart", "get_portfolio_stats", "get_position", "get_position_risk", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trades", "get_trading_pair_by_id", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "reduce_position_margin", "refresh_session", "replace_order", "revoke_delegated_agent", "revoke_session", "simulate_auto_margin_order_risk", "simulate_fees", "simulate_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_to_auto_margin_account", "transfer_collateral_to_margin_account", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
14
+ /** Union of every OpenAPI operationId in the spec. */
15
+ export type OperationId = (typeof OPERATION_IDS)[number];
@@ -0,0 +1,95 @@
1
+ /**
2
+ * GENERATED — DO NOT EDIT BY HAND.
3
+ *
4
+ * Runtime list of every OpenAPI operationId in the canonical spec
5
+ * (docs/src/proto-openapi/api/openapi.yaml), emitted by `make ts-wire-gen`
6
+ * (scripts/gen-operation-ids.ts) alongside the type-only `schema.ts`.
7
+ *
8
+ * The MON-1489 endpoint-coverage gate iterates this list to assert that every
9
+ * operationId is classified (covered or intentionally excluded) on each
10
+ * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
+ * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
+ */
13
+ export const OPERATION_IDS = [
14
+ "add_position_margin",
15
+ "attach_position_tp_sl",
16
+ "authenticate_backend",
17
+ "batch_cancel_all",
18
+ "batch_cancel_all_by_pair",
19
+ "batch_cancel_orders",
20
+ "batch_create_orders",
21
+ "batch_replace_orders",
22
+ "cancel_conditional_order",
23
+ "cancel_order",
24
+ "close_position",
25
+ "create_challenge",
26
+ "create_conditional_order",
27
+ "create_delegated_session",
28
+ "create_order",
29
+ "create_sub_account_limit",
30
+ "delete_sub_account_limit",
31
+ "ensure_parent_margin_account",
32
+ "get_application_config",
33
+ "get_application_stats",
34
+ "get_available_collateral",
35
+ "get_candles",
36
+ "get_funding_state",
37
+ "get_index_price",
38
+ "get_margin_account_movements",
39
+ "get_margin_account_summary",
40
+ "get_mark_price",
41
+ "get_market_metadata",
42
+ "get_open_interest",
43
+ "get_order_by_id",
44
+ "get_orderbook_snapshot",
45
+ "get_orders",
46
+ "get_perp_market_config",
47
+ "get_perp_market_summary",
48
+ "get_portfolio_chart",
49
+ "get_portfolio_stats",
50
+ "get_position",
51
+ "get_position_risk",
52
+ "get_screener",
53
+ "get_sub_account_limits",
54
+ "get_trade_by_id",
55
+ "get_trades",
56
+ "get_trading_pair_by_id",
57
+ "get_user_balance_by_asset",
58
+ "get_user_balances",
59
+ "get_user_movements",
60
+ "get_user_profile",
61
+ "get_user_trades",
62
+ "get_withdrawal",
63
+ "health_check",
64
+ "initiate_withdrawal",
65
+ "list_application_balances",
66
+ "list_application_movements",
67
+ "list_application_orders",
68
+ "list_application_users",
69
+ "list_conditional_orders",
70
+ "list_delegated_agent_owners",
71
+ "list_delegated_agents",
72
+ "list_funding_history",
73
+ "list_funding_payments",
74
+ "list_margin_accounts",
75
+ "list_position_history",
76
+ "list_positions",
77
+ "list_sub_accounts_with_balances",
78
+ "list_trading_pairs",
79
+ "mint_tokens",
80
+ "reduce_position_margin",
81
+ "refresh_session",
82
+ "replace_order",
83
+ "revoke_delegated_agent",
84
+ "revoke_session",
85
+ "simulate_auto_margin_order_risk",
86
+ "simulate_fees",
87
+ "simulate_order_risk",
88
+ "submit_whitelist",
89
+ "transfer_collateral_from_margin_account",
90
+ "transfer_collateral_to_auto_margin_account",
91
+ "transfer_collateral_to_margin_account",
92
+ "update_sub_account_limit",
93
+ "upsert_delegated_agent",
94
+ "verify_signature",
95
+ ];