@flexemarkets/fm-sdk 0.3.3 → 0.4.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.
package/dist/types.d.ts CHANGED
@@ -83,6 +83,57 @@ export interface ParticipantState {
83
83
  ownerEmail: string | null;
84
84
  fields: Record<string, unknown>;
85
85
  }
86
+ /**
87
+ * Who a pushed widget is for: the whole marketplace, or one participant.
88
+ *
89
+ * `scope` is `"MARKETPLACE"` or `"USER"`; `userId` names the participant for a
90
+ * `USER` widget. A user-scoped widget outranks a marketplace one of the same key
91
+ * for that participant.
92
+ */
93
+ export interface WidgetTarget {
94
+ scope: string;
95
+ userId?: number | null;
96
+ }
97
+ /**
98
+ * One widget as a study pushes it: content for the panel naming `key`.
99
+ *
100
+ * A push to the same target and key replaces the last one. `content` is a
101
+ * closed schema the server enforces -- `text`, `kv`, `table` or `log`, each a
102
+ * `kind` plus its own fields, never markup -- and is passed through as an
103
+ * object so the server's validator is the one place the rules live. An absent
104
+ * `target` means the marketplace; `emphasis` is `normal` (when absent),
105
+ * `strong` or `warn`; `ttlSeconds` blanks the panel that long after the push,
106
+ * absent for never.
107
+ */
108
+ export interface WidgetPush {
109
+ target?: WidgetTarget | null;
110
+ key: string;
111
+ title?: string | null;
112
+ emphasis?: string | null;
113
+ ttlSeconds?: number | null;
114
+ content: Record<string, unknown>;
115
+ }
116
+ /**
117
+ * One pushed widget as the server stored it.
118
+ *
119
+ * Identity is the marketplace, scope, participant and key: a push to the same
120
+ * four replaces what was there. Every widget in a marketplace is cleared when
121
+ * its session closes. `lastModifiedDate` is the last push, which is what
122
+ * `ttlSeconds` counts from.
123
+ */
124
+ export interface Widget {
125
+ id: number | null;
126
+ marketplaceId: number | null;
127
+ scope: string | null;
128
+ userId: number | null;
129
+ key: string | null;
130
+ title: string | null;
131
+ emphasis: string | null;
132
+ ttlSeconds: number | null;
133
+ content: Record<string, unknown>;
134
+ createdDate: Date | null;
135
+ lastModifiedDate: Date | null;
136
+ }
86
137
  export interface Holding {
87
138
  marketplaceId: number;
88
139
  sessionId: number;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAwGlC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,QAAgB;IAC5D,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAyC;IACzE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAmCD,+DAA+D;AAC/D,MAAM,UAAU,QAAQ;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,KAAa;IACrD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;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;CAC4B,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,KAAgC;IACrD,MAAM,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,KAAgC;IAC1D,MAAM,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAsBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;IAC3F,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This package's version, from the package.json one level above the module.
3
+ *
4
+ * That holds in both layouts: `src/` beside package.json in a checkout, and
5
+ * `dist/` beside it in the published package, which npm always ships with
6
+ * package.json. It used to read the repository's VERSION file three levels
7
+ * up, which exists only in a checkout, so an npm install reported 0.0.0 --
8
+ * and fm-server keys its endpoint metrics by this (fm-server#1012).
9
+ *
10
+ * @param from the module's own directory; a parameter only so a test can
11
+ * stand up the installed layout.
12
+ */
13
+ export declare function readVersion(from?: URL): string;
@@ -0,0 +1,25 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { join } from "node:path";
4
+ /**
5
+ * This package's version, from the package.json one level above the module.
6
+ *
7
+ * That holds in both layouts: `src/` beside package.json in a checkout, and
8
+ * `dist/` beside it in the published package, which npm always ships with
9
+ * package.json. It used to read the repository's VERSION file three levels
10
+ * up, which exists only in a checkout, so an npm install reported 0.0.0 --
11
+ * and fm-server keys its endpoint metrics by this (fm-server#1012).
12
+ *
13
+ * @param from the module's own directory; a parameter only so a test can
14
+ * stand up the installed layout.
15
+ */
16
+ export function readVersion(from = new URL(".", import.meta.url)) {
17
+ try {
18
+ const pkg = JSON.parse(readFileSync(join(fileURLToPath(from), "..", "package.json"), "utf-8"));
19
+ return typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
20
+ }
21
+ catch {
22
+ return "0.0.0";
23
+ }
24
+ }
25
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,OAAY,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/F,OAAO,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexemarkets/fm-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Flexemarkets TypeScript SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "ticker": "tsx src/ticker.ts",
20
20
  "build": "tsc",
21
21
  "check": "tsc --noEmit",
22
- "test": "node --import tsx --test test/*.test.ts",
22
+ "test": "node --import tsx --import ./test/isolated-home.ts --test --experimental-test-coverage --test-coverage-include=src/client.ts --test-coverage-include=src/desk.ts --test-coverage-include=src/stomp.ts --test-coverage-include=src/order-utils.ts --test-coverage-include=src/orderbook.ts --test-coverage-include=src/trades.ts --test-coverage-lines=95 test/*.test.ts",
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "keywords": [
package/dist/hal.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * The HAL envelope the server currently speaks.
3
- *
4
- * Not re-exported from `index.ts`, which is the package's only entry point, so
5
- * this is unreachable from outside. HAL is a transport detail: the SDK reads
6
- * `_links` to discover where things live and hands callers plain objects, so
7
- * nothing in the public surface should mention it. The server is moving to
8
- * HAL-less endpoints, and when it does this module goes away without a version
9
- * bump -- which it could not have done while `ApiRoot` was exported.
10
- *
11
- * Java keeps the same type in `fm.internal`, and Python in `fm/_hal.py`.
12
- */
13
- export interface ApiRoot {
14
- links: Record<string, string>;
15
- }
package/dist/hal.js DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * The HAL envelope the server currently speaks.
3
- *
4
- * Not re-exported from `index.ts`, which is the package's only entry point, so
5
- * this is unreachable from outside. HAL is a transport detail: the SDK reads
6
- * `_links` to discover where things live and hands callers plain objects, so
7
- * nothing in the public surface should mention it. The server is moving to
8
- * HAL-less endpoints, and when it does this module goes away without a version
9
- * bump -- which it could not have done while `ApiRoot` was exported.
10
- *
11
- * Java keeps the same type in `fm.internal`, and Python in `fm/_hal.py`.
12
- */
13
- export {};
14
- //# sourceMappingURL=hal.js.map
package/dist/hal.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hal.js","sourceRoot":"","sources":["../src/hal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}