From 969c38fe9e224fea2a84092c881c9a2a2b822df9 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Mon, 18 Nov 2024 15:57:41 +0900 Subject: [PATCH] Payment related plugin properties --- package.json | 6 +- src/IOpenAiSchema.ts | 55 +++++++------ src/ISwaggerSchema.ts | 54 +++++-------- ...lugin.ts => ISwaggerSchemaCommonPlugin.ts} | 6 +- src/ISwaggerSchemaPaymentPlugin.ts | 81 +++++++++++++++++++ src/ISwaggerSchemaSecurityPlugin.ts | 24 ++++++ src/index.ts | 24 ++++-- 7 files changed, 176 insertions(+), 74 deletions(-) rename src/{ISwaggerSchemaPlugin.ts => ISwaggerSchemaCommonPlugin.ts} (96%) create mode 100644 src/ISwaggerSchemaPaymentPlugin.ts create mode 100644 src/ISwaggerSchemaSecurityPlugin.ts diff --git a/package.json b/package.json index a27f727..d01fbba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wrtnio/schema", - "version": "1.1.0", + "version": "1.2.0", "description": "JSON and LLM function calling schemas extended for Wrtn Studio Pro", "main": "lib/index.js", "module": "./lib/index.mjs", @@ -31,10 +31,10 @@ }, "homepage": "https://github.com/wrtnio/schema#readme", "dependencies": { - "@samchon/openapi": "^1.1.0" + "@samchon/openapi": "^1.2.0" }, "peerDependencies": { - "@samchon/openapi": ">=1.1.0" + "@samchon/openapi": ">=1.2.0" }, "devDependencies": { "@rollup/plugin-terser": "^0.4.4", diff --git a/src/IOpenAiSchema.ts b/src/IOpenAiSchema.ts index 9cfbbea..0d7be01 100644 --- a/src/IOpenAiSchema.ts +++ b/src/IOpenAiSchema.ts @@ -1,6 +1,8 @@ import { ILlmSchema } from "@samchon/openapi"; -import { ISwaggerSchemaPlugin } from "./ISwaggerSchemaPlugin"; +import { ISwaggerSchemaCommonPlugin } from "./ISwaggerSchemaCommonPlugin"; +import { ISwaggerSchemaPaymentPlugin } from "./ISwaggerSchemaPaymentPlugin"; +import { ISwaggerSchemaSecurityPlugin } from "./ISwaggerSchemaSecurityPlugin"; /** * Type schema info of OpenAI (LLM) function call. @@ -35,47 +37,42 @@ export namespace IOpenAiSchema { /** * Boolean type schema info. */ - export interface IBoolean extends ILlmSchema.IBoolean, ISwaggerSchemaPlugin {} + export interface IBoolean + extends ILlmSchema.IBoolean, + ISwaggerSchemaCommonPlugin {} /** * Integer type schema info. */ - export interface IInteger extends ILlmSchema.IInteger, ISwaggerSchemaPlugin {} + export interface IInteger + extends ILlmSchema.IInteger, + ISwaggerSchemaCommonPlugin, + ISwaggerSchemaPaymentPlugin.IPriceAmount {} /** * Number type schema info. */ - export interface INumber extends ILlmSchema.INumber, ISwaggerSchemaPlugin {} + export interface INumber + extends ILlmSchema.INumber, + ISwaggerSchemaCommonPlugin, + ISwaggerSchemaPaymentPlugin.IPriceAmount {} /** * String type schema info. */ - export interface IString extends ILlmSchema.IString, ISwaggerSchemaPlugin { - /** - * Secret key for the schema. - * - * `x-wrtn-secret-key` is a property means a secret key that is required - * for the target API endpoint calling. If the secret key is not filled, - * the API call would be failed. - */ - "x-wrtn-secret-key"?: string; - - /** - * Secret scopes for the schema. - * - * `x-wrtn-secret-scopes` is a property means a list of secret scopes that - * are required for the target API endpoint calling. If the secret scopes - * are not satisfied, the API call would be failed. - */ - "x-wrtn-secret-scopes"?: string[]; - } + export interface IString + extends ILlmSchema.IString, + ISwaggerSchemaCommonPlugin, + ISwaggerSchemaPaymentPlugin.IPriceCurrency, + ISwaggerSchemaPaymentPlugin.IVendor, + ISwaggerSchemaSecurityPlugin {} /** * Array type schema info. */ export interface IArray extends Omit, - ISwaggerSchemaPlugin { + ISwaggerSchemaCommonPlugin { /** * Items type schema info. * @@ -90,7 +87,7 @@ export namespace IOpenAiSchema { */ export interface IObject extends Omit, - ISwaggerSchemaPlugin { + ISwaggerSchemaCommonPlugin { /** * Properties of the object. * @@ -125,14 +122,16 @@ export namespace IOpenAiSchema { * * It means the type of the value is `any`. */ - export interface IUnknown extends ILlmSchema.IUnknown, ISwaggerSchemaPlugin {} + export interface IUnknown + extends ILlmSchema.IUnknown, + ISwaggerSchemaCommonPlugin {} /** * Null only type schema info. */ export interface INullOnly extends ILlmSchema.INullOnly, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * One of type schema info. @@ -145,7 +144,7 @@ export namespace IOpenAiSchema { */ export interface IOneOf extends Omit, - ISwaggerSchemaPlugin { + ISwaggerSchemaCommonPlugin { /** * List of the union types. */ diff --git a/src/ISwaggerSchema.ts b/src/ISwaggerSchema.ts index 64b2adc..7d6290d 100644 --- a/src/ISwaggerSchema.ts +++ b/src/ISwaggerSchema.ts @@ -1,6 +1,8 @@ import { OpenApi } from "@samchon/openapi"; -import { ISwaggerSchemaPlugin } from "./ISwaggerSchemaPlugin"; +import { ISwaggerSchemaCommonPlugin } from "./ISwaggerSchemaCommonPlugin"; +import { ISwaggerSchemaPaymentPlugin } from "./ISwaggerSchemaPaymentPlugin"; +import { ISwaggerSchemaSecurityPlugin } from "./ISwaggerSchemaSecurityPlugin"; /** * Type schema info. @@ -23,8 +25,8 @@ import { ISwaggerSchemaPlugin } from "./ISwaggerSchemaPlugin"; * * - {@link ISwaggerSchema.IString.x-wrtn-secret-key} * - {@link ISwaggerSchema.IString.x-wrtn-secret-scopes} - * - {@link ISwaggerSchemaPlugin.x-wrtn-placeholder} - * - {@link ISwaggerSchemaPlugin.x-wrtn-prerequisite} + * - {@link ISwaggerSchemaCommonPlugin.x-wrtn-placeholder} + * - {@link ISwaggerSchemaCommonPlugin.x-wrtn-prerequisite} * * @author Samchon */ @@ -47,81 +49,67 @@ export namespace ISwaggerSchema { */ export interface IConstant extends OpenApi.IJsonSchema.IConstant, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Boolean type info. */ export interface IBoolean extends OpenApi.IJsonSchema.IBoolean, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Integer type info. */ export interface IInteger extends OpenApi.IJsonSchema.IInteger, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin, + ISwaggerSchemaPaymentPlugin.IPriceAmount {} /** * Number (double) type info. */ export interface INumber extends OpenApi.IJsonSchema.INumber, - ISwaggerSchemaPlugin {} + ISwaggerSchemaPaymentPlugin.IPriceAmount {} /** * String type info. */ export interface IString extends OpenApi.IJsonSchema.IString, - ISwaggerSchemaPlugin { - /** - * Secret key for the schema. - * - * `x-wrtn-secret-key` is a property means a secret key that is required - * for the target API endpoint calling. If the secret key is not filled, - * the API call would be failed. - */ - "x-wrtn-secret-key"?: string; - - /** - * Secret scopes for the schema. - * - * `x-wrtn-secret-scopes` is a property means a list of secret scopes that - * are required for the target API endpoint calling. If the secret scopes - * are not satisfied, the API call would be failed. - */ - "x-wrtn-secret-scopes"?: string[]; - } + ISwaggerSchemaCommonPlugin, + ISwaggerSchemaPaymentPlugin.IPriceCurrency, + ISwaggerSchemaPaymentPlugin.IVendor, + ISwaggerSchemaSecurityPlugin {} /** * Array type info. */ export interface IArray extends OpenApi.IJsonSchema.IArray, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Tuple type info. */ export interface ITuple extends OpenApi.IJsonSchema.ITuple, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Object type info. */ export interface IObject extends OpenApi.IJsonSchema.IObject, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Reference type directing named schema. */ export interface IReference extends OpenApi.IJsonSchema.IReference, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Union type. @@ -134,7 +122,7 @@ export namespace ISwaggerSchema { */ export interface IOneOf extends Omit, - ISwaggerSchemaPlugin { + ISwaggerSchemaCommonPlugin { /** * List of the union types. */ @@ -146,12 +134,12 @@ export namespace ISwaggerSchema { */ export interface INull extends OpenApi.IJsonSchema.INull, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} /** * Unknown, `any` type. */ export interface IUnknown extends OpenApi.IJsonSchema.IUnknown, - ISwaggerSchemaPlugin {} + ISwaggerSchemaCommonPlugin {} } diff --git a/src/ISwaggerSchemaPlugin.ts b/src/ISwaggerSchemaCommonPlugin.ts similarity index 96% rename from src/ISwaggerSchemaPlugin.ts rename to src/ISwaggerSchemaCommonPlugin.ts index 1ab134d..1efa8da 100644 --- a/src/ISwaggerSchemaPlugin.ts +++ b/src/ISwaggerSchemaCommonPlugin.ts @@ -3,7 +3,7 @@ * * @author Samchon */ -export interface ISwaggerSchemaPlugin { +export interface ISwaggerSchemaCommonPlugin { /** * Placeholder value for frontend application. * @@ -22,9 +22,9 @@ export interface ISwaggerSchemaPlugin { * * @reference https://github.com/wrtnio/decorators/blob/main/src/Prerequisite.ts */ - "x-wrtn-prerequisite"?: ISwaggerSchemaPlugin.IPrerequisite; + "x-wrtn-prerequisite"?: ISwaggerSchemaCommonPlugin.IPrerequisite; } -export namespace ISwaggerSchemaPlugin { +export namespace ISwaggerSchemaCommonPlugin { /** * Prerequisite API endpoint with accessors. */ diff --git a/src/ISwaggerSchemaPaymentPlugin.ts b/src/ISwaggerSchemaPaymentPlugin.ts new file mode 100644 index 0000000..c8c7e26 --- /dev/null +++ b/src/ISwaggerSchemaPaymentPlugin.ts @@ -0,0 +1,81 @@ +/** + * Collection of payment plugins. + * + * @author Samchon + */ +export namespace ISwaggerSchemaPaymentPlugin { + /** + * Price amount plugin property. + */ + export interface IPriceAmount { + /** + * The currency of the payment should be paid. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-currency` property, the value means the currency of the + * payment should be paid at the next publishing plan. + * + * The payment would be proceeded by the payment vendor service, and you + * may fill the next payment function's parameter with the vendor service + * code and UID of the payment transaction that is signified by the + * `x-wrtn-payment-vendor` and `x-wrtn-payment-uid` typed properties. + */ + "x-wrtn-payment-currency"?: true; + } + + /** + * Price currency plugin property. + */ + export interface IPriceCurrency { + /** + * The amount of the payment should be paid. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-amount` property, the value means the amount of the + * payment should be paid at the next publishing plan. + * + * The payment would be proceeded by the payment vendor service, and you + * may fill the next payment function's parameter with the vendor service + * code and UID of the payment transaction that is signified by the + * `x-wrtn-payment-vendor` and `x-wrtn-payment-uid` typed properties. + */ + "x-wrtn-payment-amount"?: true; + } + + /** + * Vendor plugin properties. + */ + export interface IVendor { + /** + * Code of the payment vendor service. + * + * When a payment function is called, its parameters may contain the + * code of the payment vendor service that is represented by the + * `x-wrtn-payment-vendor` typed property. + * + * If the target payment function's vendor service is "stripe", just fill + * the `x-wrtn-payment-vendor` property with the string "stripe". + * Otherwise, the vendor service code is "toss-payments", just fill the + * `x-wrtn-payment-vendor` typed property with the string "toss-payments". + * + * The `x-wrtn-payment-vendor` property is used to identify the payment + * vendor service and to check the payment status with the + * {@link x-wrtn-payment-uid} typed property. + */ + "x-wrtn-payment-vendor"?: true; + + /** + * UID of the payment transaction. + * + * When a payment function is called, its parameters may contain the + * UID of the payment transaction that is signified by the + * `x-wrtn-payment-uid` typed property. + * + * The UID is a unique identifier of the payment transaction that is + * proceeded by the payment vendor service. The UID is used to identify + * the payment transaction and to check the payment status with the + * {@link x-wrtn-payment-vendor} typed property. + */ + "x-wrtn-payment-uid"?: true; + } +} diff --git a/src/ISwaggerSchemaSecurityPlugin.ts b/src/ISwaggerSchemaSecurityPlugin.ts new file mode 100644 index 0000000..7b52641 --- /dev/null +++ b/src/ISwaggerSchemaSecurityPlugin.ts @@ -0,0 +1,24 @@ +/** + * Plugin properties about the security. + * + * @author Samchon + */ +export interface ISwaggerSchemaSecurityPlugin { + /** + * Secret key for the schema. + * + * `x-wrtn-secret-key` is a property means a secret key that is required + * for the target API endpoint calling. If the secret key is not filled, + * the API call would be failed. + */ + "x-wrtn-secret-key"?: string; + + /** + * Secret scopes for the schema. + * + * `x-wrtn-secret-scopes` is a property means a list of secret scopes that + * are required for the target API endpoint calling. If the secret scopes + * are not satisfied, the API call would be failed. + */ + "x-wrtn-secret-scopes"?: string[]; +} diff --git a/src/index.ts b/src/index.ts index 907e7bc..24b9479 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,28 @@ +// LLM TYPES export * from "./IHttpOpenAiApplication"; export * from "./IHttpOpenAiFunction"; export * from "./IOpenAiApplication"; export * from "./IOpenAiFunction"; + export * from "./IOpenAiSchema"; +export * from "./OpenAiTypeChecker"; + +// OPENAPI TYPES export * from "./ISwagger"; -export * from "./ISwaggerComponents"; export * from "./ISwaggerInfo"; +export * from "./ISwaggerServer"; +export * from "./ISwaggerPath"; +export * from "./ISwaggerOperation"; +export * from "./ISwaggerTag"; + export * from "./ISwaggerMigrateApplication"; export * from "./ISwaggerMigrateRoute"; -export * from "./ISwaggerOperation"; -export * from "./ISwaggerPath"; + +export * from "./ISwaggerComponents"; export * from "./ISwaggerSchema"; -export * from "./ISwaggerSchemaPlugin"; export * from "./ISwaggerSecurityScheme"; -export * from "./ISwaggerServer"; -export * from "./ISwaggerTag"; -export * from "./OpenAiTypeChecker"; + +// PLUGINS +export * from "./ISwaggerSchemaCommonPlugin"; +export * from "./ISwaggerSchemaPaymentPlugin"; +export * from "./ISwaggerSchemaSecurityPlugin";