@yuants/exchange 0.6.0 → 0.6.1
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/quote.js +9 -2
- package/dist/quote.js.map +1 -1
- package/lib/quote.d.ts.map +1 -1
- package/lib/quote.js +9 -2
- package/lib/quote.js.map +1 -1
- package/package.json +9 -9
- package/temp/package-deps.json +12 -12
package/dist/quote.js
CHANGED
|
@@ -23,11 +23,18 @@ const schemaValidator = createValidator({
|
|
|
23
23
|
properties: {
|
|
24
24
|
product_ids: {
|
|
25
25
|
type: 'object',
|
|
26
|
-
required: ['type', '
|
|
26
|
+
required: ['type', 'items'],
|
|
27
27
|
properties: {
|
|
28
28
|
type: { type: 'string', const: 'array' },
|
|
29
29
|
maxItems: { type: ['number', 'null'] },
|
|
30
|
-
|
|
30
|
+
items: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
required: ['type', 'pattern'],
|
|
33
|
+
properties: {
|
|
34
|
+
type: { type: 'string', const: 'string' },
|
|
35
|
+
pattern: { type: 'string', pattern: '^\\^' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
31
38
|
},
|
|
32
39
|
},
|
|
33
40
|
fields: {
|
package/dist/quote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;IAChC,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QACzC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,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nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { createValidator } from '@yuants/protocol/lib/schema';\nimport { newError } from '../../utils/lib';\nimport { IQuoteField, IQuoteServiceMetadata, IQuoteServiceRequestByVEX, IQuoteUpdateAction } from './types';\n\nconst schemaValidator = createValidator({\n type: 'object',\n required: ['type', 'properties'],\n properties: {\n type: { type: 'string', const: 'object' },\n required: { type: 'array', const: ['product_ids', 'fields'] },\n properties: {\n type: 'object',\n required: ['product_ids', 'fields'],\n properties: {\n product_ids: {\n type: 'object',\n required: ['type', 'items'],\n properties: {\n type: { type: 'string', const: 'array' },\n maxItems: { type: ['number', 'null'] },\n items: {\n type: 'object',\n required: ['type', 'pattern'],\n properties: {\n type: { type: 'string', const: 'string' },\n pattern: { type: 'string', pattern: '^\\\\^' },\n },\n },\n },\n },\n fields: {\n type: 'object',\n required: ['type', 'const'],\n properties: {\n type: { type: 'string', const: 'array' },\n const: { type: 'array', items: { type: 'string' } },\n },\n },\n },\n },\n },\n});\n\n/**\n * Extract Quote Service Metadata from JSON Schema\n * @public\n */\nexport const parseQuoteServiceMetadataFromSchema = (schema: any): IQuoteServiceMetadata => {\n if (!schema) throw newError('QUOTE_SERVICE_SCHEMA_MISSING', { schema });\n if (!schemaValidator(schema)) throw newError('QUOTE_SERVICE_SCHEMA_INVALID', { schema });\n\n return {\n product_id_prefix: schema.properties.product_ids.items.pattern.slice(1),\n fields: schema.properties.fields.const,\n max_products_per_request: schema.properties.product_ids.maxItems,\n };\n};\n\n/**\n * Provide Quote Service\n * @public\n */\nexport const provideQuoteService = <K extends IQuoteField>(\n terminal: Terminal,\n metadata: IQuoteServiceMetadata<K>,\n requestFunc: (\n request: IQuoteServiceRequestByVEX,\n ) => Promise<Array<Pick<IQuote, K> & { product_id: string; updated_at: number }>>,\n serviceOptions?: IServiceOptions,\n) => {\n return terminal.server.provideService<IQuoteServiceRequestByVEX, IQuoteUpdateAction>(\n 'GetQuotes',\n {\n type: 'object',\n required: ['product_ids', 'fields'],\n properties: {\n product_ids: {\n type: 'array',\n maxItems: metadata.max_products_per_request,\n items: { type: 'string', pattern: `^${metadata.product_id_prefix}` },\n },\n fields: {\n type: 'array',\n const: metadata.fields.sort(),\n },\n },\n },\n async (msg) => {\n const data = await requestFunc(msg.req);\n\n const action: IQuoteUpdateAction = {};\n for (const quote of data) {\n const { product_id, updated_at, ...fields } = quote;\n action[product_id] ??= {};\n for (const key of Object.keys(fields) as K[]) {\n const value = (fields as any)[key];\n if (value !== undefined) {\n action[product_id][key] = [value, updated_at];\n }\n }\n }\n\n return { res: { code: 0, message: 'OK', data: action } };\n },\n serviceOptions,\n );\n};\n"]}
|
package/lib/quote.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,yBAAyB,EAAsB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,yBAAyB,EAAsB,MAAM,SAAS,CAAC;AAyC5G;;;GAGG;AACH,eAAO,MAAM,mCAAmC,WAAY,GAAG,KAAG,qBASjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,oCACpB,QAAQ,6DAGP,yBAAyB;gBACe,MAAM;gBAAc,MAAM;wBAC5D,eAAe;;CAsCjC,CAAC"}
|
package/lib/quote.js
CHANGED
|
@@ -26,11 +26,18 @@ const schemaValidator = (0, schema_1.createValidator)({
|
|
|
26
26
|
properties: {
|
|
27
27
|
product_ids: {
|
|
28
28
|
type: 'object',
|
|
29
|
-
required: ['type', '
|
|
29
|
+
required: ['type', 'items'],
|
|
30
30
|
properties: {
|
|
31
31
|
type: { type: 'string', const: 'array' },
|
|
32
32
|
maxItems: { type: ['number', 'null'] },
|
|
33
|
-
|
|
33
|
+
items: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
required: ['type', 'pattern'],
|
|
36
|
+
properties: {
|
|
37
|
+
type: { type: 'string', const: 'string' },
|
|
38
|
+
pattern: { type: 'string', pattern: '^\\^' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
34
41
|
},
|
|
35
42
|
},
|
|
36
43
|
fields: {
|
package/lib/quote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,wDAA8D;AAC9D,yCAA2C;AAG3C,MAAM,eAAe,GAAG,IAAA,wBAAe,EAAC;IACtC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;IAChC,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QACzC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE;QAC7D,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;YACnC,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,wDAA8D;AA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,EAAE,GAAG,EAAE,EAAE;;QACZ,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExC,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;YACxB,MAAM,EAAE,UAAU,EAAE,UAAU,KAAgB,KAAK,EAAhB,MAAM,UAAK,KAAK,EAA7C,4BAAqC,CAAQ,CAAC;YACpD,MAAA,MAAM,CAAC,UAAU,qCAAjB,MAAM,CAAC,UAAU,IAAM,EAAE,EAAC;YAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAQ,EAAE;gBAC5C,MAAM,KAAK,GAAI,MAAc,CAAC,GAAG,CAAC,CAAC;gBACnC,IAAI,KAAK,KAAK,SAAS,EAAE;oBACvB,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;iBAC/C;aACF;SACF;QAED,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAC3D,CAAC,EACD,cAAc,CACf,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,mBAAmB,uBA4C9B","sourcesContent":["import { IQuote } from '@yuants/data-quote';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { createValidator } from '@yuants/protocol/lib/schema';\nimport { newError } from '../../utils/lib';\nimport { IQuoteField, IQuoteServiceMetadata, IQuoteServiceRequestByVEX, IQuoteUpdateAction } from './types';\n\nconst schemaValidator = createValidator({\n type: 'object',\n required: ['type', 'properties'],\n properties: {\n type: { type: 'string', const: 'object' },\n required: { type: 'array', const: ['product_ids', 'fields'] },\n properties: {\n type: 'object',\n required: ['product_ids', 'fields'],\n properties: {\n product_ids: {\n type: 'object',\n required: ['type', 'items'],\n properties: {\n type: { type: 'string', const: 'array' },\n maxItems: { type: ['number', 'null'] },\n items: {\n type: 'object',\n required: ['type', 'pattern'],\n properties: {\n type: { type: 'string', const: 'string' },\n pattern: { type: 'string', pattern: '^\\\\^' },\n },\n },\n },\n },\n fields: {\n type: 'object',\n required: ['type', 'const'],\n properties: {\n type: { type: 'string', const: 'array' },\n const: { type: 'array', items: { type: 'string' } },\n },\n },\n },\n },\n },\n});\n\n/**\n * Extract Quote Service Metadata from JSON Schema\n * @public\n */\nexport const parseQuoteServiceMetadataFromSchema = (schema: any): IQuoteServiceMetadata => {\n if (!schema) throw newError('QUOTE_SERVICE_SCHEMA_MISSING', { schema });\n if (!schemaValidator(schema)) throw newError('QUOTE_SERVICE_SCHEMA_INVALID', { schema });\n\n return {\n product_id_prefix: schema.properties.product_ids.items.pattern.slice(1),\n fields: schema.properties.fields.const,\n max_products_per_request: schema.properties.product_ids.maxItems,\n };\n};\n\n/**\n * Provide Quote Service\n * @public\n */\nexport const provideQuoteService = <K extends IQuoteField>(\n terminal: Terminal,\n metadata: IQuoteServiceMetadata<K>,\n requestFunc: (\n request: IQuoteServiceRequestByVEX,\n ) => Promise<Array<Pick<IQuote, K> & { product_id: string; updated_at: number }>>,\n serviceOptions?: IServiceOptions,\n) => {\n return terminal.server.provideService<IQuoteServiceRequestByVEX, IQuoteUpdateAction>(\n 'GetQuotes',\n {\n type: 'object',\n required: ['product_ids', 'fields'],\n properties: {\n product_ids: {\n type: 'array',\n maxItems: metadata.max_products_per_request,\n items: { type: 'string', pattern: `^${metadata.product_id_prefix}` },\n },\n fields: {\n type: 'array',\n const: metadata.fields.sort(),\n },\n },\n },\n async (msg) => {\n const data = await requestFunc(msg.req);\n\n const action: IQuoteUpdateAction = {};\n for (const quote of data) {\n const { product_id, updated_at, ...fields } = quote;\n action[product_id] ??= {};\n for (const key of Object.keys(fields) as K[]) {\n const value = (fields as any)[key];\n if (value !== undefined) {\n action[product_id][key] = [value, updated_at];\n }\n }\n }\n\n return { res: { code: 0, message: 'OK', data: action } };\n },\n serviceOptions,\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/exchange",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"typescript": "~4.7.4"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@yuants/protocol": "0.53.
|
|
28
|
-
"@yuants/data-account": "0.10.
|
|
29
|
-
"@yuants/data-order": "0.7.
|
|
30
|
-
"@yuants/data-product": "0.5.
|
|
31
|
-
"@yuants/data-quote": "0.3.
|
|
32
|
-
"@yuants/cache": "0.3.
|
|
33
|
-
"@yuants/sql": "0.9.
|
|
34
|
-
"@yuants/utils": "0.
|
|
27
|
+
"@yuants/protocol": "0.53.3",
|
|
28
|
+
"@yuants/data-account": "0.10.2",
|
|
29
|
+
"@yuants/data-order": "0.7.1",
|
|
30
|
+
"@yuants/data-product": "0.5.1",
|
|
31
|
+
"@yuants/data-quote": "0.3.1",
|
|
32
|
+
"@yuants/cache": "0.3.4",
|
|
33
|
+
"@yuants/sql": "0.9.31",
|
|
34
|
+
"@yuants/utils": "0.15.0",
|
|
35
35
|
"rxjs": "~7.5.6"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
package/temp/package-deps.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"libraries/exchange/CHANGELOG.json": "
|
|
3
|
-
"libraries/exchange/CHANGELOG.md": "
|
|
2
|
+
"libraries/exchange/CHANGELOG.json": "4ec92c4aace22f8d4c1debe545ad4682859dfe15",
|
|
3
|
+
"libraries/exchange/CHANGELOG.md": "d0d9a875649d7351557d0df46ab6bf296856704b",
|
|
4
4
|
"libraries/exchange/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
|
|
5
5
|
"libraries/exchange/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
6
6
|
"libraries/exchange/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
7
7
|
"libraries/exchange/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
8
8
|
"libraries/exchange/etc/exchange.api.md": "ebba089fe78ffc5864dd07ad41ad27b8c29ac07c",
|
|
9
|
-
"libraries/exchange/package.json": "
|
|
9
|
+
"libraries/exchange/package.json": "399bc6ec377c8690003a950fdaa4989fb4ca766a",
|
|
10
10
|
"libraries/exchange/src/index.ts": "b63a97684af91046cf6ee2df92a7561a9a088cb5",
|
|
11
|
-
"libraries/exchange/src/quote.ts": "
|
|
11
|
+
"libraries/exchange/src/quote.ts": "663393e8f22b1e11f675e05f6d3c19d06862366e",
|
|
12
12
|
"libraries/exchange/src/types.ts": "523c219c9c3c67c8ed68ffed0d3498abfe68f8d6",
|
|
13
13
|
"libraries/exchange/tsconfig.json": "22f94ca28b507f8ddcc21b9053158eefd3f726a9",
|
|
14
14
|
"libraries/exchange/.rush/temp/shrinkwrap-deps.json": "f769a3dbf84c1bff16d82dcfcefa30369a27dd36",
|
|
15
|
-
"libraries/protocol/temp/package-deps.json": "
|
|
16
|
-
"libraries/data-account/temp/package-deps.json": "
|
|
17
|
-
"libraries/data-order/temp/package-deps.json": "
|
|
18
|
-
"libraries/data-product/temp/package-deps.json": "
|
|
19
|
-
"libraries/data-quote/temp/package-deps.json": "
|
|
20
|
-
"libraries/cache/temp/package-deps.json": "
|
|
21
|
-
"libraries/sql/temp/package-deps.json": "
|
|
22
|
-
"libraries/utils/temp/package-deps.json": "
|
|
15
|
+
"libraries/protocol/temp/package-deps.json": "c94931cb0eab7180d90a06d740c1a97c0ac0c6b6",
|
|
16
|
+
"libraries/data-account/temp/package-deps.json": "61641a5eb18cbaceedb085230d86589ea8d076ae",
|
|
17
|
+
"libraries/data-order/temp/package-deps.json": "8aa3e27ff80629d417bfe920e85d8525fbb52f42",
|
|
18
|
+
"libraries/data-product/temp/package-deps.json": "899bba8ace3f04b2035488ff9059e40732ef1d97",
|
|
19
|
+
"libraries/data-quote/temp/package-deps.json": "272c0fe62ababfa66a7589139c31231a6fdce2b4",
|
|
20
|
+
"libraries/cache/temp/package-deps.json": "e1f94620bc6245add32a4f9d379ed2901129d818",
|
|
21
|
+
"libraries/sql/temp/package-deps.json": "041074e0102f9a01820c0fddcf82b9eaee226c79",
|
|
22
|
+
"libraries/utils/temp/package-deps.json": "7f1eab07acae68df931b001594a522f050ace396",
|
|
23
23
|
"tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
|
|
24
24
|
}
|