Skip to content

Commit

Permalink
Payment related plugin properties
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Nov 18, 2024
1 parent db07661 commit 969c38f
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 74 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
55 changes: 27 additions & 28 deletions src/IOpenAiSchema.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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<ILlmSchema.IArray, "items">,
ISwaggerSchemaPlugin {
ISwaggerSchemaCommonPlugin {
/**
* Items type schema info.
*
Expand All @@ -90,7 +87,7 @@ export namespace IOpenAiSchema {
*/
export interface IObject
extends Omit<ILlmSchema.IObject, "properties" | "additionalProperties">,
ISwaggerSchemaPlugin {
ISwaggerSchemaCommonPlugin {
/**
* Properties of the object.
*
Expand Down Expand Up @@ -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.
Expand All @@ -145,7 +144,7 @@ export namespace IOpenAiSchema {
*/
export interface IOneOf
extends Omit<ILlmSchema.IOneOf, "oneOf">,
ISwaggerSchemaPlugin {
ISwaggerSchemaCommonPlugin {
/**
* List of the union types.
*/
Expand Down
54 changes: 21 additions & 33 deletions src/ISwaggerSchema.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
*/
Expand All @@ -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<ISwaggerSchema>,
ISwaggerSchemaPlugin {}
ISwaggerSchemaCommonPlugin {}

/**
* Tuple type info.
*/
export interface ITuple
extends OpenApi.IJsonSchema.ITuple<ISwaggerSchema>,
ISwaggerSchemaPlugin {}
ISwaggerSchemaCommonPlugin {}

/**
* Object type info.
*/
export interface IObject
extends OpenApi.IJsonSchema.IObject<ISwaggerSchema>,
ISwaggerSchemaPlugin {}
ISwaggerSchemaCommonPlugin {}

/**
* Reference type directing named schema.
*/
export interface IReference<Key = string>
extends OpenApi.IJsonSchema.IReference<Key>,
ISwaggerSchemaPlugin {}
ISwaggerSchemaCommonPlugin {}

/**
* Union type.
Expand All @@ -134,7 +122,7 @@ export namespace ISwaggerSchema {
*/
export interface IOneOf
extends Omit<OpenApi.IJsonSchema.IOneOf, "oneOf">,
ISwaggerSchemaPlugin {
ISwaggerSchemaCommonPlugin {
/**
* List of the union types.
*/
Expand All @@ -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 {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author Samchon
*/
export interface ISwaggerSchemaPlugin {
export interface ISwaggerSchemaCommonPlugin {
/**
* Placeholder value for frontend application.
*
Expand All @@ -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.
*/
Expand Down
81 changes: 81 additions & 0 deletions src/ISwaggerSchemaPaymentPlugin.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 969c38f

Please sign in to comment.