New runner #49
+179
-21
@@ -43,8 +43,7 @@ paths:
|
|||||||
"400":
|
"400":
|
||||||
description: |-
|
description: |-
|
||||||
Returned when:
|
Returned when:
|
||||||
- a binding references a ledger the caller does not own
|
- a ledger scope reference is not one of the caller's own main ledgers
|
||||||
- a binding references a ledger that is not a main ledger
|
|
||||||
/ledgers/main/{ledgerId}:
|
/ledgers/main/{ledgerId}:
|
||||||
put:
|
put:
|
||||||
tags:
|
tags:
|
||||||
@@ -438,11 +437,38 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- rule-script
|
- rule-script
|
||||||
summary: Download the TypeScript definitions for the rule script runtime
|
summary: List the available rule script type definition files
|
||||||
operationId: getScriptDefinitions
|
operationId: listScriptDefinitions
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: The rule-runner.d.ts type definitions
|
description: The names of the available .d.ts type definitions
|
||||||
|
content:
|
||||||
|
'*/*':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
/rule-scripts/definitions/{name}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- rule-script
|
||||||
|
summary: Download a rule script type definition file by name
|
||||||
|
operationId: getScriptDefinition
|
||||||
|
parameters:
|
||||||
|
- name: name
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: The requested .d.ts type definitions
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"404":
|
||||||
|
description: No type definition with that name exists
|
||||||
content:
|
content:
|
||||||
text/plain:
|
text/plain:
|
||||||
schema:
|
schema:
|
||||||
@@ -974,8 +1000,10 @@ paths:
|
|||||||
format: uuid
|
format: uuid
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "Daily realized profit for the ledger, ascending by date, only\
|
description: "Daily FIFO-realized profit for the ledger, ascending by date,\
|
||||||
\ for days with a sale"
|
\ only for days with a sale. iskIn is the sum of that day's profitable\
|
||||||
|
\ trades, iskOut is the sum of that day's losing trades (as a positive\
|
||||||
|
\ deficit); profit is iskIn minus iskOut."
|
||||||
content:
|
content:
|
||||||
'*/*':
|
'*/*':
|
||||||
schema:
|
schema:
|
||||||
@@ -1127,50 +1155,180 @@ paths:
|
|||||||
$ref: "#/components/schemas/AcquisitionResponse"
|
$ref: "#/components/schemas/AcquisitionResponse"
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
UpdateRuleBookRequest:
|
RuleScopeRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Request to update the caller's rule book; replaces its mutable
|
description: The ledgers and other resources to bind to a rule script.
|
||||||
fields.
|
|
||||||
properties:
|
properties:
|
||||||
bindings:
|
ledgers:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
description: "Ledger references the script writes to, each bound to one\
|
description: "Ledger references the script writes to, each bound to one\
|
||||||
\ of the user's ledgers."
|
\ of the user's own main ledgers."
|
||||||
|
characters:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: "Character references the script can read, each bound to one\
|
||||||
|
\ of the user's own characters."
|
||||||
|
corporations:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: "Corporation references the script can read, each bound to\
|
||||||
|
\ a corporation of one of the user's own characters."
|
||||||
|
walletDivisions:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
$ref: "#/components/schemas/WalletDivisionTargetRequest"
|
||||||
|
description: "Corporation wallet division references the script can read,\
|
||||||
|
\ each bound to a corporation of one of the user's own characters."
|
||||||
|
required:
|
||||||
|
- characters
|
||||||
|
- corporations
|
||||||
|
- ledgers
|
||||||
|
- walletDivisions
|
||||||
|
RuleScriptRequest:
|
||||||
|
type: object
|
||||||
|
description: "A named rule script to store in the book, together with its scope."
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: Unique script name within the book; a lowercase alphanumeric
|
||||||
|
identifier.
|
||||||
|
example: sales
|
||||||
|
scope:
|
||||||
|
$ref: "#/components/schemas/RuleScopeRequest"
|
||||||
|
description: The ledgers and other resources bound to this script.
|
||||||
script:
|
script:
|
||||||
type: string
|
type: string
|
||||||
description: The classification script source.
|
description: The classification script source.
|
||||||
example: transfer.to('sales')
|
example: transfer.to('wallet')
|
||||||
required:
|
required:
|
||||||
- bindings
|
- name
|
||||||
|
- scope
|
||||||
- script
|
- script
|
||||||
|
UpdateRuleBookRequest:
|
||||||
|
type: object
|
||||||
|
description: Request to update the caller's rule book; replaces its rule scripts.
|
||||||
|
properties:
|
||||||
|
scripts:
|
||||||
|
type: array
|
||||||
|
description: The rule scripts making up the book.
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/RuleScriptRequest"
|
||||||
|
required:
|
||||||
|
- scripts
|
||||||
|
WalletDivisionTargetRequest:
|
||||||
|
type: object
|
||||||
|
description: A corporation wallet division to bind.
|
||||||
|
properties:
|
||||||
|
corporationId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: The corporation the wallet division belongs to.
|
||||||
|
example: 98000001
|
||||||
|
division:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: "The wallet division number, from 1 to 7."
|
||||||
|
example: 1
|
||||||
|
required:
|
||||||
|
- corporationId
|
||||||
|
- division
|
||||||
RuleBookResponse:
|
RuleBookResponse:
|
||||||
type: object
|
type: object
|
||||||
description: "The caller's rule book: a script that classifies transactions,\
|
description: "The caller's rule book: the named rule scripts that classify transactions,\
|
||||||
\ together with its ledger bindings."
|
\ each with its scope."
|
||||||
properties:
|
properties:
|
||||||
userId:
|
userId:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
description: Owning user identifier.
|
description: Owning user identifier.
|
||||||
example: 3fa85f64-5717-4562-b3fc-2c963f66afa6
|
example: 3fa85f64-5717-4562-b3fc-2c963f66afa6
|
||||||
bindings:
|
scripts:
|
||||||
|
type: array
|
||||||
|
description: The rule scripts making up the book.
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/RuleScriptResponse"
|
||||||
|
required:
|
||||||
|
- scripts
|
||||||
|
- userId
|
||||||
|
RuleScopeResponse:
|
||||||
|
type: object
|
||||||
|
description: The ledgers and other resources bound to a rule script.
|
||||||
|
properties:
|
||||||
|
ledgers:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
description: "Ledger references the script writes to, each bound to one\
|
description: "Ledger references the script writes to, each bound to one\
|
||||||
\ of the user's ledgers."
|
\ of the user's own main ledgers."
|
||||||
|
characters:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: "Character references the script can read, each bound to one\
|
||||||
|
\ of the user's own characters."
|
||||||
|
corporations:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: "Corporation references the script can read, each bound to\
|
||||||
|
\ a corporation of one of the user's own characters."
|
||||||
|
walletDivisions:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
$ref: "#/components/schemas/WalletDivisionTargetResponse"
|
||||||
|
description: "Corporation wallet division references the script can read,\
|
||||||
|
\ each bound to a corporation of one of the user's own characters."
|
||||||
|
required:
|
||||||
|
- characters
|
||||||
|
- corporations
|
||||||
|
- ledgers
|
||||||
|
- walletDivisions
|
||||||
|
RuleScriptResponse:
|
||||||
|
type: object
|
||||||
|
description: "A named rule script within the book, together with its scope."
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: Unique script name within the book.
|
||||||
|
example: sales
|
||||||
|
scope:
|
||||||
|
$ref: "#/components/schemas/RuleScopeResponse"
|
||||||
|
description: The ledgers and other resources bound to this script.
|
||||||
script:
|
script:
|
||||||
type: string
|
type: string
|
||||||
description: The classification script source.
|
description: The classification script source.
|
||||||
example: transfer.to('sales')
|
example: transfer.to('wallet')
|
||||||
required:
|
required:
|
||||||
- bindings
|
- name
|
||||||
|
- scope
|
||||||
- script
|
- script
|
||||||
- userId
|
WalletDivisionTargetResponse:
|
||||||
|
type: object
|
||||||
|
description: A corporation wallet division bound to the script.
|
||||||
|
properties:
|
||||||
|
corporationId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
description: The corporation the wallet division belongs to.
|
||||||
|
example: 98000001
|
||||||
|
division:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: "The wallet division number, from 1 to 7."
|
||||||
|
example: 1
|
||||||
|
required:
|
||||||
|
- corporationId
|
||||||
|
- division
|
||||||
UpdateMainLedgerRequest:
|
UpdateMainLedgerRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Request to update an existing main ledger.
|
description: Request to update an existing main ledger.
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ useEventListener('keyup', e => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="root" class="dropdown" :class="{'dropdown-open': isOpen, 'dropdown-close': !isOpen}" v-on-click-outside="[doAutoClose, { ignore: [floating] }]">
|
<div ref="root" class="dropdown" :class="{'dropdown-open': isOpen, 'dropdown-close': !isOpen}" v-on-click-outside="[doAutoClose, { ignore: [floating] }]">
|
||||||
<button @click="isOpen = !isOpen" class="cursor-pointer">
|
<button @click="isOpen = !isOpen" class="flex items-center cursor-pointer border-none bg-transparent hover:bg-transparent p-0">
|
||||||
<Transition
|
<Transition
|
||||||
|
mode="out-in"
|
||||||
enter-active-class="transition-transform"
|
enter-active-class="transition-transform"
|
||||||
enter-from-class="rotate-180"
|
enter-from-class="rotate-180">
|
||||||
leave-active-class="hidden"
|
|
||||||
leave-to-class="rotate-180">
|
|
||||||
<ChevronDownIcon v-if="!isOpen" class="chevron" />
|
<ChevronDownIcon v-if="!isOpen" class="chevron" />
|
||||||
<ChevronUpIcon v-else class="chevron" />
|
<ChevronUpIcon v-else class="chevron" />
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|||||||
+183
-21
@@ -732,7 +732,7 @@ export interface ReprocessingResultResponse {
|
|||||||
'output': Array<MarketTypeStackAppraisalResponse>;
|
'output': Array<MarketTypeStackAppraisalResponse>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The caller\'s rule book: a script that classifies transactions, together with its ledger bindings.
|
* The caller\'s rule book: the named rule scripts that classify transactions, each with its scope.
|
||||||
*/
|
*/
|
||||||
export interface RuleBookResponse {
|
export interface RuleBookResponse {
|
||||||
/**
|
/**
|
||||||
@@ -740,9 +740,81 @@ export interface RuleBookResponse {
|
|||||||
*/
|
*/
|
||||||
'userId': string;
|
'userId': string;
|
||||||
/**
|
/**
|
||||||
* Ledger references the script writes to, each bound to one of the user\'s ledgers.
|
* The rule scripts making up the book.
|
||||||
*/
|
*/
|
||||||
'bindings': { [key: string]: string; };
|
'scripts': Array<RuleScriptResponse>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The ledgers and other resources to bind to a rule script.
|
||||||
|
*/
|
||||||
|
export interface RuleScopeRequest {
|
||||||
|
/**
|
||||||
|
* Ledger references the script writes to, each bound to one of the user\'s own main ledgers.
|
||||||
|
*/
|
||||||
|
'ledgers': { [key: string]: string; };
|
||||||
|
/**
|
||||||
|
* Character references the script can read, each bound to one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'characters': { [key: string]: number; };
|
||||||
|
/**
|
||||||
|
* Corporation references the script can read, each bound to a corporation of one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'corporations': { [key: string]: number; };
|
||||||
|
/**
|
||||||
|
* Corporation wallet division references the script can read, each bound to a corporation of one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'walletDivisions': { [key: string]: WalletDivisionTargetRequest; };
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The ledgers and other resources bound to a rule script.
|
||||||
|
*/
|
||||||
|
export interface RuleScopeResponse {
|
||||||
|
/**
|
||||||
|
* Ledger references the script writes to, each bound to one of the user\'s own main ledgers.
|
||||||
|
*/
|
||||||
|
'ledgers': { [key: string]: string; };
|
||||||
|
/**
|
||||||
|
* Character references the script can read, each bound to one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'characters': { [key: string]: number; };
|
||||||
|
/**
|
||||||
|
* Corporation references the script can read, each bound to a corporation of one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'corporations': { [key: string]: number; };
|
||||||
|
/**
|
||||||
|
* Corporation wallet division references the script can read, each bound to a corporation of one of the user\'s own characters.
|
||||||
|
*/
|
||||||
|
'walletDivisions': { [key: string]: WalletDivisionTargetResponse; };
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A named rule script to store in the book, together with its scope.
|
||||||
|
*/
|
||||||
|
export interface RuleScriptRequest {
|
||||||
|
/**
|
||||||
|
* Unique script name within the book; a lowercase alphanumeric identifier.
|
||||||
|
*/
|
||||||
|
'name': string;
|
||||||
|
/**
|
||||||
|
* The ledgers and other resources bound to this script.
|
||||||
|
*/
|
||||||
|
'scope': RuleScopeRequest;
|
||||||
|
/**
|
||||||
|
* The classification script source.
|
||||||
|
*/
|
||||||
|
'script': string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A named rule script within the book, together with its scope.
|
||||||
|
*/
|
||||||
|
export interface RuleScriptResponse {
|
||||||
|
/**
|
||||||
|
* Unique script name within the book.
|
||||||
|
*/
|
||||||
|
'name': string;
|
||||||
|
/**
|
||||||
|
* The ledgers and other resources bound to this script.
|
||||||
|
*/
|
||||||
|
'scope': RuleScopeResponse;
|
||||||
/**
|
/**
|
||||||
* The classification script source.
|
* The classification script source.
|
||||||
*/
|
*/
|
||||||
@@ -805,17 +877,39 @@ export interface UpdateMainLedgerRequest {
|
|||||||
'name': string;
|
'name': string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Request to update the caller\'s rule book; replaces its mutable fields.
|
* Request to update the caller\'s rule book; replaces its rule scripts.
|
||||||
*/
|
*/
|
||||||
export interface UpdateRuleBookRequest {
|
export interface UpdateRuleBookRequest {
|
||||||
/**
|
/**
|
||||||
* Ledger references the script writes to, each bound to one of the user\'s ledgers.
|
* The rule scripts making up the book.
|
||||||
*/
|
*/
|
||||||
'bindings': { [key: string]: string; };
|
'scripts': Array<RuleScriptRequest>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A corporation wallet division to bind.
|
||||||
|
*/
|
||||||
|
export interface WalletDivisionTargetRequest {
|
||||||
/**
|
/**
|
||||||
* The classification script source.
|
* The corporation the wallet division belongs to.
|
||||||
*/
|
*/
|
||||||
'script': string;
|
'corporationId': number;
|
||||||
|
/**
|
||||||
|
* The wallet division number, from 1 to 7.
|
||||||
|
*/
|
||||||
|
'division': number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A corporation wallet division bound to the script.
|
||||||
|
*/
|
||||||
|
export interface WalletDivisionTargetResponse {
|
||||||
|
/**
|
||||||
|
* The corporation the wallet division belongs to.
|
||||||
|
*/
|
||||||
|
'corporationId': number;
|
||||||
|
/**
|
||||||
|
* The wallet division number, from 1 to 7.
|
||||||
|
*/
|
||||||
|
'division': number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3909,12 +4003,16 @@ export const RuleScriptApiAxiosParamCreator = function (configuration?: Configur
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Download the TypeScript definitions for the rule script runtime
|
* @summary Download a rule script type definition file by name
|
||||||
|
* @param {string} name
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getScriptDefinitions: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
getScriptDefinition: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
const localVarPath = `/rule-scripts/definitions`;
|
// verify required parameter 'name' is not null or undefined
|
||||||
|
assertParamExists('getScriptDefinition', 'name', name)
|
||||||
|
const localVarPath = `/rule-scripts/definitions/{name}`
|
||||||
|
.replace('{name}', encodeURIComponent(String(name)));
|
||||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
let baseOptions;
|
let baseOptions;
|
||||||
@@ -3932,6 +4030,36 @@ export const RuleScriptApiAxiosParamCreator = function (configuration?: Configur
|
|||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: toPathString(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary List the available rule script type definition files
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
listScriptDefinitions: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/rule-scripts/definitions`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
localVarHeaderParameter['Accept'] = '*/*';
|
||||||
|
|
||||||
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: toPathString(localVarUrlObj),
|
url: toPathString(localVarUrlObj),
|
||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
@@ -3948,14 +4076,27 @@ export const RuleScriptApiFp = function(configuration?: Configuration) {
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Download the TypeScript definitions for the rule script runtime
|
* @summary Download a rule script type definition file by name
|
||||||
|
* @param {string} name
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async getScriptDefinitions(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
|
async getScriptDefinition(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
|
||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getScriptDefinitions(options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.getScriptDefinition(name, options);
|
||||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||||
const localVarOperationServerBasePath = operationServerMap['RuleScriptApi.getScriptDefinitions']?.[localVarOperationServerIndex]?.url;
|
const localVarOperationServerBasePath = operationServerMap['RuleScriptApi.getScriptDefinition']?.[localVarOperationServerIndex]?.url;
|
||||||
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary List the available rule script type definition files
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async listScriptDefinitions(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
||||||
|
const localVarAxiosArgs = await localVarAxiosParamCreator.listScriptDefinitions(options);
|
||||||
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||||
|
const localVarOperationServerBasePath = operationServerMap['RuleScriptApi.listScriptDefinitions']?.[localVarOperationServerIndex]?.url;
|
||||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -3969,12 +4110,22 @@ export const RuleScriptApiFactory = function (configuration?: Configuration, bas
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Download the TypeScript definitions for the rule script runtime
|
* @summary Download a rule script type definition file by name
|
||||||
|
* @param {string} name
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getScriptDefinitions(options?: RawAxiosRequestConfig): AxiosPromise<string> {
|
getScriptDefinition(name: string, options?: RawAxiosRequestConfig): AxiosPromise<string> {
|
||||||
return localVarFp.getScriptDefinitions(options).then((request) => request(axios, basePath));
|
return localVarFp.getScriptDefinition(name, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary List the available rule script type definition files
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
listScriptDefinitions(options?: RawAxiosRequestConfig): AxiosPromise<Array<string>> {
|
||||||
|
return localVarFp.listScriptDefinitions(options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -3985,12 +4136,23 @@ export const RuleScriptApiFactory = function (configuration?: Configuration, bas
|
|||||||
export class RuleScriptApi extends BaseAPI {
|
export class RuleScriptApi extends BaseAPI {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Download the TypeScript definitions for the rule script runtime
|
* @summary Download a rule script type definition file by name
|
||||||
|
* @param {string} name
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
public getScriptDefinitions(options?: RawAxiosRequestConfig) {
|
public getScriptDefinition(name: string, options?: RawAxiosRequestConfig) {
|
||||||
return RuleScriptApiFp(this.configuration).getScriptDefinitions(options).then((request) => request(this.axios, this.basePath));
|
return RuleScriptApiFp(this.configuration).getScriptDefinition(name, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary List the available rule script type definition files
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
public listScriptDefinitions(options?: RawAxiosRequestConfig) {
|
||||||
|
return RuleScriptApiFp(this.configuration).listScriptDefinitions(options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,46 +4,132 @@ import {useEventListener} from "@vueuse/core";
|
|||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {ScriptEditor, useRuleBookStore} from "@/rules";
|
import {ScriptEditor, useRuleBookStore} from "@/rules";
|
||||||
import {PlusIcon, TrashIcon} from "@heroicons/vue/24/outline";
|
import {PlusIcon, TrashIcon} from "@heroicons/vue/24/outline";
|
||||||
|
import {Dropdown} from "@/components";
|
||||||
import {isMain, Ledger, LedgerSelect, systemLedger, useLedgersStore} from "@/ledger";
|
import {isMain, Ledger, LedgerSelect, systemLedger, useLedgersStore} from "@/ledger";
|
||||||
|
import {useCharactersStore} from "@/characters";
|
||||||
|
import {CorporationLabel, useCorporationsStore} from "@/corporations";
|
||||||
|
import {RuleScriptRequest} from "@/generated/mammon";
|
||||||
import {toast} from "@/toast";
|
import {toast} from "@/toast";
|
||||||
|
import {confirm} from "@/confirm";
|
||||||
|
|
||||||
type Binding = { ref: string; ledger: Ledger };
|
type LedgerScopeEntry = { ref: string; ledger: Ledger };
|
||||||
|
type CharacterScopeEntry = { ref: string; characterId: number };
|
||||||
|
type CorporationScopeEntry = { ref: string; corporationId: number };
|
||||||
|
type WalletDivisionScopeEntry = { ref: string; corporationId: number; division: number };
|
||||||
|
|
||||||
|
interface ScriptDraft {
|
||||||
|
name: string;
|
||||||
|
script: string;
|
||||||
|
ledgers: LedgerScopeEntry[];
|
||||||
|
characters: CharacterScopeEntry[];
|
||||||
|
corporations: CorporationScopeEntry[];
|
||||||
|
walletDivisions: WalletDivisionScopeEntry[];
|
||||||
|
}
|
||||||
|
|
||||||
const ruleBookStore = useRuleBookStore();
|
const ruleBookStore = useRuleBookStore();
|
||||||
const ledgersStore = useLedgersStore();
|
const ledgersStore = useLedgersStore();
|
||||||
|
const charactersStore = useCharactersStore();
|
||||||
|
const corporationsStore = useCorporationsStore();
|
||||||
|
|
||||||
const ledgersToUse = computed(() => [systemLedger, ...ledgersStore.ledgers.filter(isMain)]);
|
const ledgersToUse = computed(() => [systemLedger, ...ledgersStore.ledgers.filter(isMain)]);
|
||||||
|
|
||||||
const bindings = ref<Binding[]>([]);
|
const scripts = ref<ScriptDraft[]>([]);
|
||||||
const script = ref<string>('');
|
const selectedIndex = ref(0);
|
||||||
|
const scopesExpanded = ref(true);
|
||||||
const ledgerRefs = computed<string[]>(() => bindings.value.map(b => b.ref));
|
const ledgersExpanded = ref(true);
|
||||||
|
const charactersExpanded = ref(true);
|
||||||
|
const corporationsExpanded = ref(true);
|
||||||
|
const walletDivisionsExpanded = ref(true);
|
||||||
|
const selected = computed<ScriptDraft | undefined>(() => scripts.value[selectedIndex.value]);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
const ruleBook = ruleBookStore.ruleBook;
|
const ruleBook = ruleBookStore.ruleBook;
|
||||||
|
|
||||||
script.value = ruleBook?.script ?? '';
|
scripts.value = (ruleBook?.scripts ?? []).map(script => ({
|
||||||
bindings.value = Object.entries(ruleBook?.bindings ?? {})
|
name: script.name,
|
||||||
.map(([ref, id]) => ({ref, ledger: ledgersToUse.value.find(l => l.ledgerId === id) ?? systemLedger}));
|
script: script.script,
|
||||||
|
ledgers: Object.entries(script.scope.ledgers).map(([ref, id]) => ({ref, ledger: ledgersToUse.value.find(l => l.ledgerId === id) ?? systemLedger})),
|
||||||
|
characters: Object.entries(script.scope.characters).map(([ref, characterId]) => ({ref, characterId})),
|
||||||
|
corporations: Object.entries(script.scope.corporations).map(([ref, corporationId]) => ({ref, corporationId})),
|
||||||
|
walletDivisions: Object.entries(script.scope.walletDivisions).map(([ref, target]) => ({ref, corporationId: target.corporationId, division: target.division})),
|
||||||
|
}));
|
||||||
|
selectedIndex.value = 0;
|
||||||
log.info('Loaded rule book:', ruleBook);
|
log.info('Loaded rule book:', ruleBook);
|
||||||
});
|
});
|
||||||
|
|
||||||
const addBinding = () => {
|
const editorScope = computed(() => selected.value ? {
|
||||||
bindings.value = [...bindings.value, {ref: '', ledger: systemLedger}];
|
ledgers: selected.value.ledgers.map(entry => entry.ref),
|
||||||
|
characters: selected.value.characters.map(entry => entry.ref),
|
||||||
|
corporations: selected.value.corporations.map(entry => entry.ref),
|
||||||
|
walletDivisions: selected.value.walletDivisions.map(entry => entry.ref),
|
||||||
|
} : undefined);
|
||||||
|
|
||||||
|
const scriptText = computed<string>({
|
||||||
|
get: () => selected.value?.script ?? '',
|
||||||
|
set: value => {
|
||||||
|
if (selected.value) {
|
||||||
|
selected.value.script = value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const addScript = () => {
|
||||||
|
scripts.value = [...scripts.value, {name: '', script: '', ledgers: [], characters: [], corporations: [], walletDivisions: []}];
|
||||||
|
selectedIndex.value = scripts.value.length - 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeBinding = (index: number) => {
|
const removeScript = async (index: number) => {
|
||||||
bindings.value = bindings.value.toSpliced(index, 1);
|
const script = scripts.value[index];
|
||||||
|
|
||||||
|
if (script?.script.trim() && !await confirm({message: `Delete script "${script.name || '(unnamed)'}"? It still has content.`, danger: true})) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scripts.value = scripts.value.toSpliced(index, 1);
|
||||||
|
if (selectedIndex.value >= scripts.value.length) {
|
||||||
|
selectedIndex.value = Math.max(0, scripts.value.length - 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = () => ruleBookStore.update({
|
const addLedgerScope = () => selected.value?.ledgers.push({ref: '', ledger: systemLedger});
|
||||||
bindings: Object.fromEntries(
|
const removeLedgerScope = (index: number) => { if (selected.value) selected.value.ledgers = selected.value.ledgers.toSpliced(index, 1); };
|
||||||
bindings.value
|
|
||||||
.filter(b => b.ref)
|
const addCharacterScope = () => selected.value?.characters.push({ref: '', characterId: charactersStore.characters[0]?.characterId ?? 0});
|
||||||
.map(b => [b.ref, b.ledger.ledgerId])
|
const removeCharacterScope = (index: number) => { if (selected.value) selected.value.characters = selected.value.characters.toSpliced(index, 1); };
|
||||||
),
|
|
||||||
script: script.value
|
const addCorporationScope = () => selected.value?.corporations.push({ref: '', corporationId: 0});
|
||||||
})
|
const removeCorporationScope = (index: number) => { if (selected.value) selected.value.corporations = selected.value.corporations.toSpliced(index, 1); };
|
||||||
|
|
||||||
|
const addWalletDivisionScope = () => selected.value?.walletDivisions.push({ref: '', corporationId: 0, division: 1});
|
||||||
|
const removeWalletDivisionScope = (index: number) => { if (selected.value) selected.value.walletDivisions = selected.value.walletDivisions.toSpliced(index, 1); };
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
const corporationIds = new Set([
|
||||||
|
...(selected.value?.corporations.map(entry => entry.corporationId) ?? []),
|
||||||
|
...(selected.value?.walletDivisions.map(entry => entry.corporationId) ?? []),
|
||||||
|
]);
|
||||||
|
|
||||||
|
for (const corporationId of corporationIds) {
|
||||||
|
if (corporationId) {
|
||||||
|
corporationsStore.findById(corporationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const save = () => ruleBookStore.update(
|
||||||
|
scripts.value
|
||||||
|
.filter(s => s.name)
|
||||||
|
.map((s): RuleScriptRequest => ({
|
||||||
|
name: s.name,
|
||||||
|
script: s.script,
|
||||||
|
scope: {
|
||||||
|
ledgers: Object.fromEntries(s.ledgers.filter(entry => entry.ref).map(entry => [entry.ref, entry.ledger.ledgerId])),
|
||||||
|
characters: Object.fromEntries(s.characters.filter(entry => entry.ref).map(entry => [entry.ref, entry.characterId])),
|
||||||
|
corporations: Object.fromEntries(s.corporations.filter(entry => entry.ref).map(entry => [entry.ref, entry.corporationId])),
|
||||||
|
walletDivisions: Object.fromEntries(s.walletDivisions.filter(entry => entry.ref).map(entry => [entry.ref, {corporationId: entry.corporationId, division: entry.division}])),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
)
|
||||||
.then(() => toast.success('Rule book saved'));
|
.then(() => toast.success('Rule book saved'));
|
||||||
|
|
||||||
useEventListener(window, 'keydown', (event: KeyboardEvent) => {
|
useEventListener(window, 'keydown', (event: KeyboardEvent) => {
|
||||||
@@ -55,31 +141,104 @@ useEventListener(window, 'keydown', (event: KeyboardEvent) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col mb-2 mt-4 h-[calc(100vh-4.5rem)]">
|
<div class="flex mb-2 mt-4 h-[calc(100vh-1.5rem)]">
|
||||||
<div class="flex flex-col grow min-h-0">
|
<div class="flex flex-col me-4 w-48 shrink-0">
|
||||||
<div class="border-b-1">
|
<div class="grow overflow-y-auto">
|
||||||
Ledger Bindings:
|
<div v-for="(script, index) in scripts" :key="index"
|
||||||
<div class="flex flex-wrap items-center mt-2">
|
class="flex items-center mb-1 px-1 py-0.5 border-l-4 cursor-pointer"
|
||||||
<div class="flex items-center mb-2 me-2" v-for="(binding, index) in bindings" :key="index">
|
:class="index === selectedIndex ? 'border-emerald-500' : 'border-transparent'"
|
||||||
<input class="me-1" type="text" v-model="binding.ref" />
|
@click="selectedIndex = index">
|
||||||
<span class="me-1">:</span>
|
<span class="grow truncate">{{ script.name || '(unnamed)' }}</span>
|
||||||
<LedgerSelect class="me-1" :ledgers="ledgersToUse" v-model="binding.ledger" />
|
<button class="btn-icon text-amber-700 hover:text-amber-600" @click.stop="removeScript(index)"><TrashIcon /></button>
|
||||||
<button class="btn-icon text-amber-700 hover:text-amber-600" @click="removeBinding(index)"><TrashIcon /></button>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center mb-2">
|
|
||||||
<button class="btn-icon" @click="addBinding"><PlusIcon /></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button class="btn-icon flex items-center" @click="addScript"><PlusIcon /> Add script</button>
|
||||||
<div class="flex flex-col grow min-h-0 border-b-1">
|
|
||||||
Script:
|
|
||||||
<ScriptEditor class="mt-2 mb-2" v-model="script" :ledgerRefs="ledgerRefs" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 justify-end flex">
|
|
||||||
<div>
|
<div v-if="selected" class="flex flex-col grow min-h-0">
|
||||||
|
<div class="border-b-1 mb-2 pb-2">
|
||||||
|
Name: <input class="me-1" type="text" v-model="selected.name" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dropdown inline :auto-close="false" v-model:open="scopesExpanded" class="mb-2">
|
||||||
|
<template #button>Scopes</template>
|
||||||
|
<Dropdown inline :auto-close="false" v-model:open="ledgersExpanded" class="ms-4 mt-2">
|
||||||
|
<template #button>Ledgers</template>
|
||||||
|
<div class="flex flex-wrap items-center mt-2">
|
||||||
|
<div class="flex items-center mb-2 me-2" v-for="(entry, index) in selected.ledgers" :key="index">
|
||||||
|
<input class="me-1" type="text" v-model="entry.ref" />
|
||||||
|
<span class="me-1">:</span>
|
||||||
|
<LedgerSelect class="me-1" :ledgers="ledgersToUse" v-model="entry.ledger" />
|
||||||
|
<button class="btn-icon text-amber-700 hover:text-amber-600" @click="removeLedgerScope(index)"><TrashIcon /></button>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center mb-2">
|
||||||
|
<button class="btn-icon" @click="addLedgerScope"><PlusIcon /></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
|
||||||
|
<Dropdown inline :auto-close="false" v-model:open="charactersExpanded" class="ms-4 mt-2">
|
||||||
|
<template #button>Characters</template>
|
||||||
|
<div class="flex flex-wrap items-center mt-2">
|
||||||
|
<div class="flex items-center mb-2 me-2" v-for="(entry, index) in selected.characters" :key="index">
|
||||||
|
<input class="me-1" type="text" v-model="entry.ref" />
|
||||||
|
<span class="me-1">:</span>
|
||||||
|
<select class="me-1" v-model="entry.characterId">
|
||||||
|
<option v-for="character in charactersStore.characters" :key="character.characterId" :value="character.characterId">{{ character.name }}</option>
|
||||||
|
</select>
|
||||||
|
<button class="btn-icon text-amber-700 hover:text-amber-600" @click="removeCharacterScope(index)"><TrashIcon /></button>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center mb-2">
|
||||||
|
<button class="btn-icon" @click="addCharacterScope"><PlusIcon /></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
|
||||||
|
<Dropdown inline :auto-close="false" v-model:open="corporationsExpanded" class="ms-4 mt-2">
|
||||||
|
<template #button>Corporations</template>
|
||||||
|
<div class="flex flex-wrap items-center mt-2">
|
||||||
|
<div class="flex items-center mb-2 me-2" v-for="(entry, index) in selected.corporations" :key="index">
|
||||||
|
<input class="me-1" type="text" v-model="entry.ref" />
|
||||||
|
<span class="me-1">:</span>
|
||||||
|
<input class="me-1 w-32" type="number" v-model.number="entry.corporationId" placeholder="Corporation ID" />
|
||||||
|
<CorporationLabel class="me-1" :corporation-id="entry.corporationId" :corporation="corporationsStore.corporations[entry.corporationId]" :size="16" v-if="entry.corporationId" />
|
||||||
|
<button class="btn-icon text-amber-700 hover:text-amber-600" @click="removeCorporationScope(index)"><TrashIcon /></button>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center mb-2">
|
||||||
|
<button class="btn-icon" @click="addCorporationScope"><PlusIcon /></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
|
||||||
|
<Dropdown inline :auto-close="false" v-model:open="walletDivisionsExpanded" class="ms-4 mt-2 mb-2">
|
||||||
|
<template #button>Wallet Divisions</template>
|
||||||
|
<div class="flex flex-wrap items-center mt-2">
|
||||||
|
<div class="flex items-center mb-2 me-2" v-for="(entry, index) in selected.walletDivisions" :key="index">
|
||||||
|
<input class="me-1" type="text" v-model="entry.ref" />
|
||||||
|
<span class="me-1">:</span>
|
||||||
|
<input class="me-1 w-32" type="number" v-model.number="entry.corporationId" placeholder="Corporation ID" />
|
||||||
|
<input class="me-1 w-16" type="number" min="1" max="7" v-model.number="entry.division" placeholder="Division" />
|
||||||
|
<CorporationLabel class="me-1" :corporation-id="entry.corporationId" :corporation="corporationsStore.corporations[entry.corporationId]" :division="entry.division" :size="16" v-if="entry.corporationId" />
|
||||||
|
<button class="btn-icon text-amber-700 hover:text-amber-600" @click="removeWalletDivisionScope(index)"><TrashIcon /></button>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center mb-2">
|
||||||
|
<button class="btn-icon" @click="addWalletDivisionScope"><PlusIcon /></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
</Dropdown>
|
||||||
|
|
||||||
|
<div class="flex flex-col grow min-h-0 border-b-1">
|
||||||
|
Script:
|
||||||
|
<ScriptEditor class="mt-2 mb-2" v-model="scriptText" :scope="editorScope" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2 justify-end flex">
|
||||||
<button @click="save">Save</button>
|
<button @click="save">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="flex grow items-center justify-center text-neutral-500">
|
||||||
|
No scripts yet
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
+27
-13
@@ -22,27 +22,41 @@ const loadScriptDefinitions = async () => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const definitions = await fetchScriptDefinitions();
|
const definitions = await fetchScriptDefinitions();
|
||||||
monaco.typescript.javascriptDefaults.addExtraLib(definitions, 'ts:rule-runner.d.ts');
|
monaco.typescript.javascriptDefaults.addExtraLib(definitions, 'file:///node_modules/@eveal/runtime/index.d.ts');
|
||||||
extraLibLoaded = true;
|
extraLibLoaded = true;
|
||||||
} catch {
|
} catch {
|
||||||
// type definitions are optional — the editor still works without autocomplete
|
// type definitions are optional — the editor still works without autocomplete
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const props = defineProps<{ ledgerRefs?: string[] }>();
|
export interface ScriptEditorScope {
|
||||||
|
ledgers?: string[];
|
||||||
|
characters?: string[];
|
||||||
|
corporations?: string[];
|
||||||
|
walletDivisions?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
let ledgersLib: monaco.IDisposable | undefined;
|
const props = defineProps<{ scope?: ScriptEditorScope }>();
|
||||||
|
|
||||||
const updateLedgerRefs = (refs: readonly string[]) => {
|
let scopeLib: monaco.IDisposable | undefined;
|
||||||
ledgersLib?.dispose();
|
|
||||||
|
const declareInterface = (name: string, type: string, refs: readonly string[]) => {
|
||||||
const members = refs
|
const members = refs
|
||||||
.filter(ref => ref && ref !== 'system')
|
.filter(ref => ref && ref !== 'system')
|
||||||
.map(ref => ` readonly ${JSON.stringify(ref)}: Ledger;`)
|
.map(ref => ` readonly ${JSON.stringify(ref)}: ${type};`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
ledgersLib = monaco.typescript.javascriptDefaults.addExtraLib(
|
return ` interface ${name} {\n${members}\n }\n`;
|
||||||
`declare interface Ledgers {\n${members}\n}\n`,
|
};
|
||||||
'ts:rule-runner.ledgers.d.ts'
|
|
||||||
);
|
const updateScope = (scope: ScriptEditorScope) => {
|
||||||
|
scopeLib?.dispose();
|
||||||
|
const source = `declare module '@eveal/runtime' {\n${[
|
||||||
|
declareInterface('Ledgers', 'Ledger', scope.ledgers ?? []),
|
||||||
|
declareInterface('Characters', 'Character', scope.characters ?? []),
|
||||||
|
declareInterface('Corporations', 'Corporation', scope.corporations ?? []),
|
||||||
|
declareInterface('WalletDivisions', 'WalletDivision', scope.walletDivisions ?? []),
|
||||||
|
].join('\n')}}\n`;
|
||||||
|
scopeLib = monaco.typescript.javascriptDefaults.addExtraLib(source, 'ts:rule-runner.scope.d.ts');
|
||||||
};
|
};
|
||||||
|
|
||||||
const model = defineModel<string>({default: ''});
|
const model = defineModel<string>({default: ''});
|
||||||
@@ -51,7 +65,7 @@ let editor: monaco.editor.IStandaloneCodeEditor | undefined;
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadScriptDefinitions();
|
await loadScriptDefinitions();
|
||||||
updateLedgerRefs(props.ledgerRefs ?? []);
|
updateScope(props.scope ?? {});
|
||||||
|
|
||||||
if (!container.value) {
|
if (!container.value) {
|
||||||
return;
|
return;
|
||||||
@@ -83,11 +97,11 @@ watch(model, value => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(() => props.ledgerRefs, refs => updateLedgerRefs(refs ?? []), {deep: true});
|
watch(() => props.scope, scope => updateScope(scope ?? {}), {deep: true});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
editor?.dispose();
|
editor?.dispose();
|
||||||
ledgersLib?.dispose();
|
scopeLib?.dispose();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+16
-3
@@ -1,10 +1,19 @@
|
|||||||
import {ruleBookApi, ruleScriptApi} from "@/mammon";
|
import {ruleBookApi, ruleScriptApi} from "@/mammon";
|
||||||
import {RuleBookResponse, UpdateRuleBookRequest} from "@/generated/mammon";
|
import {RuleBookResponse, RuleScopeRequest, RuleScriptRequest, RuleScriptResponse, UpdateRuleBookRequest} from "@/generated/mammon";
|
||||||
import {isAxiosError} from "axios";
|
import {isAxiosError} from "axios";
|
||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
|
|
||||||
export type RuleBook = RuleBookResponse;
|
export type RuleBook = RuleBookResponse;
|
||||||
|
export type RuleScript = RuleScriptResponse;
|
||||||
|
export type RuleScope = RuleScriptResponse['scope'];
|
||||||
|
|
||||||
|
export const emptyScope = (): RuleScopeRequest => ({
|
||||||
|
ledgers: {},
|
||||||
|
characters: {},
|
||||||
|
corporations: {},
|
||||||
|
walletDivisions: {},
|
||||||
|
});
|
||||||
|
|
||||||
export const useRuleBookStore = defineStore('rule-book', () => {
|
export const useRuleBookStore = defineStore('rule-book', () => {
|
||||||
const ruleBook = ref<RuleBook | null>(null);
|
const ruleBook = ref<RuleBook | null>(null);
|
||||||
@@ -19,7 +28,7 @@ export const useRuleBookStore = defineStore('rule-book', () => {
|
|||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
const update = (request: UpdateRuleBookRequest) => ruleBookApi.updateRuleBook(request)
|
const update = (scripts: RuleScriptRequest[]) => ruleBookApi.updateRuleBook({scripts} satisfies UpdateRuleBookRequest)
|
||||||
.then(response => ruleBook.value = response.data);
|
.then(response => ruleBook.value = response.data);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
@@ -28,4 +37,8 @@ export const useRuleBookStore = defineStore('rule-book', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const fetchScriptDefinitions = (): Promise<string> =>
|
export const fetchScriptDefinitions = (): Promise<string> =>
|
||||||
ruleScriptApi.getScriptDefinitions({responseType: 'text'}).then(response => response.data);
|
ruleScriptApi.listScriptDefinitions()
|
||||||
|
.then(response => Promise.all(
|
||||||
|
response.data.map(name => ruleScriptApi.getScriptDefinition(name, {responseType: 'text'}).then(r => r.data))
|
||||||
|
))
|
||||||
|
.then(definitions => definitions.join('\n'));
|
||||||
|
|||||||
Reference in New Issue
Block a user