diff --git a/docs/mammon-api.yml b/docs/mammon-api.yml index a8c89b0..2f8bee0 100644 --- a/docs/mammon-api.yml +++ b/docs/mammon-api.yml @@ -6,6 +6,57 @@ servers: - url: http://localhost:8080 description: Generated server url paths: + /rule-books/{ruleBookId}: + get: + tags: + - rule-book-controller + operationId: findRuleBookById + parameters: + - name: ruleBookId + in: path + required: true + schema: + type: string + format: uuid + responses: + "404": + description: Not Found + "400": + description: Bad Request + "200": + description: OK + content: + '*/*': + schema: + $ref: "#/components/schemas/RuleBookResponse" + put: + tags: + - rule-book-controller + operationId: updateRuleBook + parameters: + - name: ruleBookId + in: path + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateRuleBookRequest" + required: true + responses: + "404": + description: Not Found + "400": + description: Bad Request + "200": + description: OK + content: + '*/*': + schema: + $ref: "#/components/schemas/RuleBookResponse" /ledgers/main/{ledgerId}: put: tags: @@ -64,6 +115,45 @@ paths: '*/*': schema: $ref: "#/components/schemas/CombinedLedgerResponse" + /rule-books: + get: + tags: + - rule-book-controller + operationId: findAllRuleBooks + responses: + "404": + description: Not Found + "400": + description: Bad Request + "200": + description: OK + content: + '*/*': + schema: + type: array + items: + $ref: "#/components/schemas/RuleBookResponse" + post: + tags: + - rule-book-controller + operationId: createRuleBook + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateRuleBookRequest" + required: true + responses: + "404": + description: Not Found + "400": + description: Bad Request + "200": + description: OK + content: + '*/*': + schema: + $ref: "#/components/schemas/RuleBookResponse" /process-activities: post: tags: @@ -120,57 +210,6 @@ paths: '*/*': schema: $ref: "#/components/schemas/CombinedLedgerResponse" - /characters/{characterId}/rule-book: - get: - tags: - - rule-book-controller - operationId: findByCharacterId - parameters: - - name: characterId - in: path - required: true - schema: - type: integer - format: int64 - responses: - "404": - description: Not Found - "400": - description: Bad Request - "200": - description: OK - content: - '*/*': - schema: - $ref: "#/components/schemas/RuleBookResponse" - post: - tags: - - rule-book-controller - operationId: setCharacterRuleBook - parameters: - - name: characterId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/SetCharacterRuleBookRequest" - required: true - responses: - "404": - description: Not Found - "400": - description: Bad Request - "200": - description: OK - content: - '*/*': - schema: - $ref: "#/components/schemas/RuleBookResponse" /activity/fetch/{characterId}: post: tags: @@ -194,7 +233,7 @@ paths: get: tags: - ledger-controller - operationId: findAll + operationId: findAllLedgers responses: "404": description: Not Found @@ -214,7 +253,7 @@ paths: get: tags: - ledger-controller - operationId: findById + operationId: findLedgerById parameters: - name: ledgerId in: path @@ -239,7 +278,7 @@ paths: get: tags: - character-controller - operationId: getCharacters + operationId: findAllCharacters responses: "404": description: Not Found @@ -255,6 +294,72 @@ paths: $ref: "#/components/schemas/CharacterResponse" components: schemas: + RuleClauseResponse: + type: object + properties: + rate: + type: string + enum: + - NONE + - VALUE + - JITA_BUY + - JITA_SELL + - EVE_ESTIMATE + fromLedgerRef: + type: string + toLedgerRef: + type: string + required: + - fromLedgerRef + - rate + - toLedgerRef + RuleResponse: + type: object + properties: + rules: + type: array + items: + $ref: "#/components/schemas/RuleClauseResponse" + required: + - rules + UpdateRuleBookRequest: + type: object + properties: + name: + type: string + ledgerRefs: + type: array + items: + type: string + rules: + type: object + additionalProperties: + $ref: "#/components/schemas/RuleResponse" + required: + - ledgerRefs + - name + - rules + RuleBookResponse: + type: object + properties: + ruleBookId: + type: string + format: uuid + name: + type: string + ledgerRefs: + type: array + items: + type: string + rules: + type: object + additionalProperties: + $ref: "#/components/schemas/RuleResponse" + required: + - ledgerRefs + - name + - ruleBookId + - rules UpdateMainLedgerRequest: type: object properties: @@ -321,6 +426,23 @@ components: - ledgerId - memberLedgerIds - name + CreateRuleBookRequest: + type: object + properties: + name: + type: string + ledgerRefs: + type: array + items: + type: string + rules: + type: object + additionalProperties: + $ref: "#/components/schemas/RuleResponse" + required: + - ledgerRefs + - name + - rules CreateMainLedgerRequest: type: object properties: @@ -341,56 +463,6 @@ components: required: - memberLedgerIds - name - RuleResponse: - type: object - properties: - rate: - type: string - enum: - - NONE - - VALUE - - JITA_BUY - - JITA_SELL - - EVE_ESTIMATE - fromLedgerId: - type: string - format: uuid - toLedgerId: - type: string - format: uuid - required: - - rate - RuleSetResponse: - type: object - properties: - rules: - type: array - items: - $ref: "#/components/schemas/RuleResponse" - required: - - rules - SetCharacterRuleBookRequest: - type: object - properties: - ruleSets: - type: object - additionalProperties: - $ref: "#/components/schemas/RuleSetResponse" - required: - - ruleSets - RuleBookResponse: - type: object - properties: - characterId: - type: integer - format: int64 - ruleSets: - type: object - additionalProperties: - $ref: "#/components/schemas/RuleSetResponse" - required: - - characterId - - ruleSets LedgerResponse: type: object discriminator: diff --git a/src/characters/chartacters.ts b/src/characters/chartacters.ts index 1c9dba4..9e50c8b 100644 --- a/src/characters/chartacters.ts +++ b/src/characters/chartacters.ts @@ -20,7 +20,7 @@ export const useCharactersStore = defineStore('characters', () => { const reloadActivities = (characterId: number): Promise => activityControllerApi.fetchNewActivitiesForCharacter(characterId) as Promise; - const refresh = () => characterControllerApi.getCharacters().then(response => characters.value = response.data); + const refresh = () => characterControllerApi.findAllCharacters().then(response => characters.value = response.data); refresh(); diff --git a/src/generated/mammon/api.ts b/src/generated/mammon/api.ts index 5831e35..6269e46 100644 --- a/src/generated/mammon/api.ts +++ b/src/generated/mammon/api.ts @@ -48,10 +48,15 @@ export interface CreateCombinedLedgerRequest { export interface CreateMainLedgerRequest { 'name': string; } +export interface CreateRuleBookRequest { + 'name': string; + 'ledgerRefs': Array; + 'rules': { [key: string]: RuleResponse; }; +} /** - * @type FindAll200ResponseInner + * @type FindAllLedgers200ResponseInner */ -export type FindAll200ResponseInner = CombinedLedgerResponse | MainLedgerResponse; +export type FindAllLedgers200ResponseInner = CombinedLedgerResponse | MainLedgerResponse; export interface LedgerResponse { 'type'?: LedgerResponseTypeEnum; @@ -78,13 +83,15 @@ export const MainLedgerResponseTypeEnum = { export type MainLedgerResponseTypeEnum = typeof MainLedgerResponseTypeEnum[keyof typeof MainLedgerResponseTypeEnum]; export interface RuleBookResponse { - 'characterId': number; + 'ruleBookId': string; + 'name': string; + 'ledgerRefs': Array; 'rules': { [key: string]: RuleResponse; }; } export interface RuleClauseResponse { 'rate': RuleClauseResponseRateEnum; - 'fromLedgerId'?: string; - 'toLedgerId'?: string; + 'fromLedgerRef': string; + 'toLedgerRef': string; } export const RuleClauseResponseRateEnum = { @@ -100,9 +107,6 @@ export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof export interface RuleResponse { 'rules': Array; } -export interface SetCharacterRuleBookRequest { - 'rules': { [key: string]: RuleResponse; }; -} export interface UpdateCombinedLedgerRequest { 'name': string; 'memberLedgerIds': Array; @@ -110,6 +114,11 @@ export interface UpdateCombinedLedgerRequest { export interface UpdateMainLedgerRequest { 'name': string; } +export interface UpdateRuleBookRequest { + 'name': string; + 'ledgerRefs': Array; + 'rules': { [key: string]: RuleResponse; }; +} /** * ActivityControllerApi - axios parameter creator @@ -217,7 +226,7 @@ export const CharacterControllerApiAxiosParamCreator = function (configuration?: * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getCharacters: async (options: RawAxiosRequestConfig = {}): Promise => { + findAllCharacters: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/characters`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -255,10 +264,10 @@ export const CharacterControllerApiFp = function(configuration?: Configuration) * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async getCharacters(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getCharacters(options); + async findAllCharacters(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findAllCharacters(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['CharacterControllerApi.getCharacters']?.[localVarOperationServerIndex]?.url; + const localVarOperationServerBasePath = operationServerMap['CharacterControllerApi.findAllCharacters']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, } @@ -275,8 +284,8 @@ export const CharacterControllerApiFactory = function (configuration?: Configura * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getCharacters(options?: RawAxiosRequestConfig): AxiosPromise> { - return localVarFp.getCharacters(options).then((request) => request(axios, basePath)); + findAllCharacters(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.findAllCharacters(options).then((request) => request(axios, basePath)); }, }; }; @@ -290,8 +299,8 @@ export class CharacterControllerApi extends BaseAPI { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public getCharacters(options?: RawAxiosRequestConfig) { - return CharacterControllerApiFp(this.configuration).getCharacters(options).then((request) => request(this.axios, this.basePath)); + public findAllCharacters(options?: RawAxiosRequestConfig) { + return CharacterControllerApiFp(this.configuration).findAllCharacters(options).then((request) => request(this.axios, this.basePath)); } } @@ -375,7 +384,7 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findAll: async (options: RawAxiosRequestConfig = {}): Promise => { + findAllLedgers: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/ledgers`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -405,9 +414,9 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findById: async (ledgerId: string, options: RawAxiosRequestConfig = {}): Promise => { + findLedgerById: async (ledgerId: string, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'ledgerId' is not null or undefined - assertParamExists('findById', 'ledgerId', ledgerId) + assertParamExists('findLedgerById', 'ledgerId', ledgerId) const localVarPath = `/ledgers/{ledgerId}` .replace('{ledgerId}', encodeURIComponent(String(ledgerId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. @@ -546,10 +555,10 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async findAll(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options); + async findAllLedgers(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findAllLedgers(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAll']?.[localVarOperationServerIndex]?.url; + const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAllLedgers']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** @@ -558,10 +567,10 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async findById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.findById(ledgerId, options); + async findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findLedgerById(ledgerId, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findById']?.[localVarOperationServerIndex]?.url; + const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findLedgerById']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** @@ -622,8 +631,8 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findAll(options?: RawAxiosRequestConfig): AxiosPromise> { - return localVarFp.findAll(options).then((request) => request(axios, basePath)); + findAllLedgers(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.findAllLedgers(options).then((request) => request(axios, basePath)); }, /** * @@ -631,8 +640,8 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.findById(ledgerId, options).then((request) => request(axios, basePath)); + findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.findLedgerById(ledgerId, options).then((request) => request(axios, basePath)); }, /** * @@ -686,8 +695,8 @@ export class LedgerControllerApi extends BaseAPI { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public findAll(options?: RawAxiosRequestConfig) { - return LedgerControllerApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath)); + public findAllLedgers(options?: RawAxiosRequestConfig) { + return LedgerControllerApiFp(this.configuration).findAllLedgers(options).then((request) => request(this.axios, this.basePath)); } /** @@ -696,8 +705,8 @@ export class LedgerControllerApi extends BaseAPI { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public findById(ledgerId: string, options?: RawAxiosRequestConfig) { - return LedgerControllerApiFp(this.configuration).findById(ledgerId, options).then((request) => request(this.axios, this.basePath)); + public findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig) { + return LedgerControllerApiFp(this.configuration).findLedgerById(ledgerId, options).then((request) => request(this.axios, this.basePath)); } /** @@ -821,15 +830,45 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?: return { /** * - * @param {number} characterId + * @param {CreateRuleBookRequest} createRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findByCharacterId: async (characterId: number, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'characterId' is not null or undefined - assertParamExists('findByCharacterId', 'characterId', characterId) - const localVarPath = `/characters/{characterId}/rule-book` - .replace('{characterId}', encodeURIComponent(String(characterId))); + createRuleBook: async (createRuleBookRequest: CreateRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'createRuleBookRequest' is not null or undefined + assertParamExists('createRuleBook', 'createRuleBookRequest', createRuleBookRequest) + const localVarPath = `/rule-books`; + // 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: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + localVarHeaderParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Accept'] = '*/*'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(createRuleBookRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findAllRuleBooks: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/rule-books`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -854,18 +893,15 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?: }, /** * - * @param {number} characterId - * @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest + * @param {string} ruleBookId * @param {*} [options] Override http request option. * @throws {RequiredError} */ - setCharacterRuleBook: async (characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'characterId' is not null or undefined - assertParamExists('setCharacterRuleBook', 'characterId', characterId) - // verify required parameter 'setCharacterRuleBookRequest' is not null or undefined - assertParamExists('setCharacterRuleBook', 'setCharacterRuleBookRequest', setCharacterRuleBookRequest) - const localVarPath = `/characters/{characterId}/rule-book` - .replace('{characterId}', encodeURIComponent(String(characterId))); + findRuleBookById: async (ruleBookId: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'ruleBookId' is not null or undefined + assertParamExists('findRuleBookById', 'ruleBookId', ruleBookId) + const localVarPath = `/rule-books/{ruleBookId}` + .replace('{ruleBookId}', encodeURIComponent(String(ruleBookId))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -873,7 +909,43 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?: baseOptions = configuration.baseOptions; } - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + 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 { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} ruleBookId + * @param {UpdateRuleBookRequest} updateRuleBookRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateRuleBook: async (ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'ruleBookId' is not null or undefined + assertParamExists('updateRuleBook', 'ruleBookId', ruleBookId) + // verify required parameter 'updateRuleBookRequest' is not null or undefined + assertParamExists('updateRuleBook', 'updateRuleBookRequest', updateRuleBookRequest) + const localVarPath = `/rule-books/{ruleBookId}` + .replace('{ruleBookId}', encodeURIComponent(String(ruleBookId))); + // 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: 'PUT', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -883,7 +955,7 @@ export const RuleBookControllerApiAxiosParamCreator = function (configuration?: setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(setCharacterRuleBookRequest, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(updateRuleBookRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -901,27 +973,50 @@ export const RuleBookControllerApiFp = function(configuration?: Configuration) { return { /** * - * @param {number} characterId + * @param {CreateRuleBookRequest} createRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async findByCharacterId(characterId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.findByCharacterId(characterId, options); + async createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createRuleBook(createRuleBookRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findByCharacterId']?.[localVarOperationServerIndex]?.url; + const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.createRuleBook']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * - * @param {number} characterId - * @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options); + async findAllRuleBooks(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findAllRuleBooks(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.setCharacterRuleBook']?.[localVarOperationServerIndex]?.url; + const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findAllRuleBooks']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @param {string} ruleBookId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findRuleBookById(ruleBookId, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.findRuleBookById']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @param {string} ruleBookId + * @param {UpdateRuleBookRequest} updateRuleBookRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updateRuleBook(ruleBookId, updateRuleBookRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['RuleBookControllerApi.updateRuleBook']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, } @@ -935,22 +1030,39 @@ export const RuleBookControllerApiFactory = function (configuration?: Configurat return { /** * - * @param {number} characterId + * @param {CreateRuleBookRequest} createRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findByCharacterId(characterId: number, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.findByCharacterId(characterId, options).then((request) => request(axios, basePath)); + createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.createRuleBook(createRuleBookRequest, options).then((request) => request(axios, basePath)); }, /** * - * @param {number} characterId - * @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options).then((request) => request(axios, basePath)); + findAllRuleBooks(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.findAllRuleBooks(options).then((request) => request(axios, basePath)); + }, + /** + * + * @param {string} ruleBookId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.findRuleBookById(ruleBookId, options).then((request) => request(axios, basePath)); + }, + /** + * + * @param {string} ruleBookId + * @param {UpdateRuleBookRequest} updateRuleBookRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.updateRuleBook(ruleBookId, updateRuleBookRequest, options).then((request) => request(axios, basePath)); }, }; }; @@ -961,23 +1073,42 @@ export const RuleBookControllerApiFactory = function (configuration?: Configurat export class RuleBookControllerApi extends BaseAPI { /** * - * @param {number} characterId + * @param {CreateRuleBookRequest} createRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public findByCharacterId(characterId: number, options?: RawAxiosRequestConfig) { - return RuleBookControllerApiFp(this.configuration).findByCharacterId(characterId, options).then((request) => request(this.axios, this.basePath)); + public createRuleBook(createRuleBookRequest: CreateRuleBookRequest, options?: RawAxiosRequestConfig) { + return RuleBookControllerApiFp(this.configuration).createRuleBook(createRuleBookRequest, options).then((request) => request(this.axios, this.basePath)); } /** * - * @param {number} characterId - * @param {SetCharacterRuleBookRequest} setCharacterRuleBookRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public setCharacterRuleBook(characterId: number, setCharacterRuleBookRequest: SetCharacterRuleBookRequest, options?: RawAxiosRequestConfig) { - return RuleBookControllerApiFp(this.configuration).setCharacterRuleBook(characterId, setCharacterRuleBookRequest, options).then((request) => request(this.axios, this.basePath)); + public findAllRuleBooks(options?: RawAxiosRequestConfig) { + return RuleBookControllerApiFp(this.configuration).findAllRuleBooks(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @param {string} ruleBookId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + public findRuleBookById(ruleBookId: string, options?: RawAxiosRequestConfig) { + return RuleBookControllerApiFp(this.configuration).findRuleBookById(ruleBookId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @param {string} ruleBookId + * @param {UpdateRuleBookRequest} updateRuleBookRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + public updateRuleBook(ruleBookId: string, updateRuleBookRequest: UpdateRuleBookRequest, options?: RawAxiosRequestConfig) { + return RuleBookControllerApiFp(this.configuration).updateRuleBook(ruleBookId, updateRuleBookRequest, options).then((request) => request(this.axios, this.basePath)); } } diff --git a/src/ledger/ledger.ts b/src/ledger/ledger.ts index b01c4a0..122faee 100644 --- a/src/ledger/ledger.ts +++ b/src/ledger/ledger.ts @@ -20,6 +20,8 @@ export type MainLedger = MainLedgerResponse & {type: MainLedgerResponseTypeEnum} export type CombinedLedger = CombinedLedgerResponse & {type: CombinedLedgerResponseTypeEnum} export type Ledger = MainLedger | CombinedLedger; + +export const systemLedgerRef = 'system'; export const systemLedger = { type: LedgerTypes.Main, ledgerId: "", @@ -62,7 +64,7 @@ export const useLedgersStore = defineStore('ledgers', () => { const updateMain = (ledgerId: string, ledger: UpdateMainLedgerRequest) => ledgerControllerApi.updateMainLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger)); const updateCombined = (ledgerId: string, ledger: UpdateCombinedLedgerRequest) => ledgerControllerApi.updateCombinedLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger)); - const refresh = () => ledgerControllerApi.findAll().then(response => ledgers.value = response.data as Ledger[]); + const refresh = () => ledgerControllerApi.findAllLedgers().then(response => ledgers.value = response.data as Ledger[]); refresh(); diff --git a/src/pages/Market.vue b/src/pages/Market.vue index c2e93a9..d4cc44c 100644 --- a/src/pages/Market.vue +++ b/src/pages/Market.vue @@ -1,6 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/src/pages/Rules.vue b/src/pages/Rules.vue index 84ff7ed..24db91c 100644 --- a/src/pages/Rules.vue +++ b/src/pages/Rules.vue @@ -1,7 +1,18 @@ \ No newline at end of file diff --git a/src/pages/rules/EditRuleBook.vue b/src/pages/rules/EditRuleBook.vue index 001390c..8151064 100644 --- a/src/pages/rules/EditRuleBook.vue +++ b/src/pages/rules/EditRuleBook.vue @@ -1,57 +1,101 @@ \ No newline at end of file diff --git a/src/pages/rules/ListCharacterRuleBooks.vue b/src/pages/rules/ListCharacterRuleBooks.vue new file mode 100644 index 0000000..8c5ca3d --- /dev/null +++ b/src/pages/rules/ListCharacterRuleBooks.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/src/pages/rules/ListRuleBooks.vue b/src/pages/rules/ListRuleBooks.vue index 8c5ca3d..d7be907 100644 --- a/src/pages/rules/ListRuleBooks.vue +++ b/src/pages/rules/ListRuleBooks.vue @@ -1,17 +1,21 @@ \ No newline at end of file diff --git a/src/routes.ts b/src/routes.ts index 67a0e7d..6c1e7ea 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -9,8 +9,14 @@ export const routes: RouteRecordRaw[] = [ ]}, {path: '/rules', component: () => import('@/pages/Rules.vue'), children: [ - {path: '', component: () => import('./pages/rules/ListRuleBooks.vue')}, - {path: '/characters/:characterId/rule-book', name: 'character-rulebook', component: () => import('@/pages/rules/EditRuleBook.vue')}, + {path: '', redirect: '/rule-books'}, + {path: '/rule-books', children: [ + {path: '', name: 'list-rule-books', component: () => import('./pages/rules/ListRuleBooks.vue')}, + {path: 'new', name: 'new-rule-book', component: () => import('@/pages/rules/EditRuleBook.vue')}, + {path: ':ruleBookId', name: 'edit-rule-book', component: () => import('@/pages/rules/EditRuleBook.vue')}, + ]}, + {path: '/characters/rules', component: () => import('./pages/rules/ListCharacterRuleBooks.vue')}, + {path: '/characters/:characterId/rules', name: 'character-rulebook', component: () => import('@/pages/rules/EditRuleBook.vue')}, ]}, {path: '/market', component: () => import('@/pages/Market.vue'), children: [ diff --git a/src/rules/RuleClauseInput.vue b/src/rules/RuleClauseInput.vue index 3127921..62877c1 100644 --- a/src/rules/RuleClauseInput.vue +++ b/src/rules/RuleClauseInput.vue @@ -1,37 +1,57 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/src/rules/RuleInput.vue b/src/rules/RuleInput.vue index 563ac21..b0f9e58 100644 --- a/src/rules/RuleInput.vue +++ b/src/rules/RuleInput.vue @@ -6,7 +6,13 @@ import {computed, useTemplateRef} from "vue"; import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline'; import {useSortable} from "@vueuse/integrations/useSortable"; -const rule = defineModel(); +interface Props { + ledgerRefs: string[]; +} + +const props = defineProps() + +const rule = defineModel({default: {rules:{}}}); const rules = computed({ get: () => rule.value && rule.value.rules ? rule.value.rules : [], set: value => rule.value = {rules: value} @@ -38,7 +44,7 @@ useSortable(sortableContainer, rules, { handle: '.sortable-handle'}); - + diff --git a/src/rules/rules.ts b/src/rules/rules.ts index 7faad64..36e9be3 100644 --- a/src/rules/rules.ts +++ b/src/rules/rules.ts @@ -1,5 +1,7 @@ -import {ruleBookControllerApi} from "@/mammon"; -import {RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon"; +import {ledgerControllerApi, ruleBookControllerApi} from "@/mammon"; +import {CreateRuleBookRequest, RuleBookResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon"; +import {defineStore} from "pinia"; +import {ref, triggerRef} from "vue"; export const activityTypes = { itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"}, @@ -10,7 +12,8 @@ export const activityTypes = { export type Activity = { key: ActivityType, name: string } export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key']; -export type RuleBook = RuleBookResponse & { rules: { [key: ActivityType]: RuleResponse; } } +export type Rules = { [key: ActivityType]: RuleResponse; }; +export type RuleBook = RuleBookResponse & { rules: Rules } export const ratesTypes = { None: {key: "NONE", name: "0 ISK"}, @@ -22,7 +25,37 @@ export const ratesTypes = { export type Rate = { key: RuleClauseResponseRateEnum, name: string } -export const findByCharacterId = (characterId: number): Promise => ruleBookControllerApi.findByCharacterId(characterId) +export const useRuleBooksStore = defineStore('rule-books', () => { + const ruleBooks = ref([]); + + const addRuleBook = (ruleBook: RuleBook) => { + ruleBooks.value.push(ruleBook); + triggerRef(ruleBooks); + return ruleBook; + }; + + const replaceRuleBook = (ruleBook: RuleBook) => { + const index = ruleBooks.value.findIndex(rb => rb.ruleBookId === ruleBook.ruleBookId); + + if (index !== -1) { + ruleBooks.value[index] = ruleBook; + } + triggerRef(ruleBooks); + return ruleBook; + }; + + const findById = (ruleBookId: string): RuleBook | undefined => ruleBooks.value.find(rb => rb.ruleBookId === ruleBookId); + const create = (ruleBook: CreateRuleBookRequest) => ruleBookControllerApi.createRuleBook(ruleBook).then(response => addRuleBook(response.data)); + const update = (ruleBookId: string, ruleBook: CreateRuleBookRequest) => ledgerControllerApi.updateMainLedger(ruleBookId, ruleBook).then(response => replaceRuleBook(response.data)); + + const refresh = () => ruleBookControllerApi.findAllRuleBooks().then(response => ruleBooks.value = response.data as RuleBook[]); + + refresh(); + + return {ruleBooks, findById, create, update, refresh}; +}) + +export const findByCharacterId = (characterId: number): Promise => ruleBookControllerApi.findById(characterId) .then(response => response.data) .catch(() => ({characterId, rules: {}})); diff --git a/src/style.css b/src/style.css index 11130a1..abe5520 100644 --- a/src/style.css +++ b/src/style.css @@ -72,9 +72,17 @@ } .btn-icon { - @apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent; + @apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent cursor-pointer; > svg { @apply w-6 h-6; } } + + a.tab { + @apply flex items-center px-4 me-2 rounded-t-md bg-slate-600 hover:bg-slate-700; + + &.router-link-active { + @apply bg-emerald-500 hover:bg-emerald-700; + } + } } \ No newline at end of file