From a0a2f9a011746be8dd26a52b762c06fc19be95ba Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 19 Nov 2024 18:11:56 +0900 Subject: [PATCH] Enhanced payment plugin properties --- package.json | 2 +- src/IOpenAiSchema.ts | 10 +--- src/ISwaggerSchema.ts | 10 +--- src/ISwaggerSchemaPaymentPlugin.ts | 89 +++++++++++++++++++++++------- 4 files changed, 75 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index d74f967..44e7da1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wrtnio/schema", - "version": "1.2.1", + "version": "1.2.2", "description": "JSON and LLM function calling schemas extended for Wrtn Studio Pro", "main": "lib/index.js", "module": "./lib/index.mjs", diff --git a/src/IOpenAiSchema.ts b/src/IOpenAiSchema.ts index d15a1a2..fd22785 100644 --- a/src/IOpenAiSchema.ts +++ b/src/IOpenAiSchema.ts @@ -47,8 +47,7 @@ export namespace IOpenAiSchema { export interface IInteger extends ILlmSchema.IInteger, ISwaggerSchemaCommonPlugin, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceAmount {} + ISwaggerSchemaPaymentPlugin.INumeric {} /** * Number type schema info. @@ -56,8 +55,7 @@ export namespace IOpenAiSchema { export interface INumber extends ILlmSchema.INumber, ISwaggerSchemaCommonPlugin, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceAmount {} + ISwaggerSchemaPaymentPlugin.INumeric {} /** * String type schema info. @@ -65,9 +63,7 @@ export namespace IOpenAiSchema { export interface IString extends ILlmSchema.IString, ISwaggerSchemaCommonPlugin, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceCurrency, - ISwaggerSchemaPaymentPlugin.IVendor, + ISwaggerSchemaPaymentPlugin.IString, ISwaggerSchemaSecurityPlugin {} /** diff --git a/src/ISwaggerSchema.ts b/src/ISwaggerSchema.ts index 1ea8755..ebc05e0 100644 --- a/src/ISwaggerSchema.ts +++ b/src/ISwaggerSchema.ts @@ -64,16 +64,14 @@ export namespace ISwaggerSchema { export interface IInteger extends OpenApi.IJsonSchema.IInteger, ISwaggerSchemaCommonPlugin, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceAmount {} + ISwaggerSchemaPaymentPlugin.INumeric {} /** * Number (double) type info. */ export interface INumber extends OpenApi.IJsonSchema.INumber, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceAmount {} + ISwaggerSchemaPaymentPlugin.INumeric {} /** * String type info. @@ -81,9 +79,7 @@ export namespace ISwaggerSchema { export interface IString extends OpenApi.IJsonSchema.IString, ISwaggerSchemaCommonPlugin, - ISwaggerSchemaPaymentPlugin.ITargetOrder, - ISwaggerSchemaPaymentPlugin.IPriceCurrency, - ISwaggerSchemaPaymentPlugin.IVendor, + ISwaggerSchemaPaymentPlugin.IString, ISwaggerSchemaSecurityPlugin {} /** diff --git a/src/ISwaggerSchemaPaymentPlugin.ts b/src/ISwaggerSchemaPaymentPlugin.ts index 9d59255..98ac06f 100644 --- a/src/ISwaggerSchemaPaymentPlugin.ts +++ b/src/ISwaggerSchemaPaymentPlugin.ts @@ -5,9 +5,9 @@ */ export namespace ISwaggerSchemaPaymentPlugin { /** - * Target of the payment. + * Plugin properties for `integer` and `number` types. */ - export interface ITargetOrder { + export interface INumeric { /** * The payment target. * @@ -22,18 +22,13 @@ export namespace ISwaggerSchemaPaymentPlugin { * issued by the payment vendor service. In other words, * `x-wrtn-payment-order-id` is issued by the target API function. */ - "x-wrtn-payment-order-id"?: string; - } + "x-wrtn-payment-order-id"?: true; - /** - * Price amount plugin property. - */ - export interface IPriceAmount { /** - * The currency of the payment should be paid. + * The amount 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 + * `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 @@ -41,18 +36,18 @@ export namespace ISwaggerSchemaPaymentPlugin { * 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; + "x-wrtn-payment-amount"?: true; } /** - * Price currency plugin property. + * Plugin properties for the `string` type. */ - export interface IPriceCurrency { + export interface IString { /** - * The amount of the payment should be paid. + * The currency 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 + * `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 @@ -60,13 +55,8 @@ export namespace ISwaggerSchemaPaymentPlugin { * 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; - } + "x-wrtn-payment-currency"?: true; - /** - * Vendor plugin properties. - */ - export interface IVendor { /** * Code of the payment vendor service. * @@ -98,5 +88,62 @@ export namespace ISwaggerSchemaPaymentPlugin { * {@link x-wrtn-payment-vendor} typed property. */ "x-wrtn-payment-uid"?: true; + + /** + * The payment target's order ID. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-target` property, the value means the identifier + * of the payment target, as an order. + * + * When processing the publish, you have to fill the next payment + * function's parameter with the target order's ID. Note that, this + * `x-wrtn-payment-order-id` is different with the + * {@link IVendor.x-wrtn-payment-uid}, which means the transation ID + * issued by the payment vendor service. In other words, + * `x-wrtn-payment-order-id` is issued by the target API function. + */ + "x-wrtn-payment-order-id"?: true; + + /** + * The payment target's order name. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-order-name` property, the value means the name of the + * payment target, as an order. + * + * When processing the publish, you have to fill the next payment + * function's parameter with the target order's name. + * + * Note that, this `x-wrtn-payment-order-name` is different with the + * {@link IVendor.x-wrtn-payment-order-citizen}. This is not the name + * or citizen, but of the target order. + */ + "x-wrtn-payment-order-name"?: true; + + /** + * The citizen who've ordered the payment. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-order-citizen` property, the value means the citizen + * who've ordered the payment. + * + * When processing the publish, you have to fill the next payment + * function's parameter with the citizen who've ordered the payment. + */ + "x-wrtn-payment-order-citizen"?: true; + + /** + * The mobile phone number of the citizen who've ordered the payment. + * + * If an order appliance function be called and it returns a value with + * `x-wrtn-payment-order-mobile` property, the value means the mobile + * phone number of the citizen who've ordered the payment. + * + * When processing the publish, you have to fill the next payment + * function's parameter with the mobile phone number of the citizen + * who've ordered the payment. + */ + "x-wrtn-payment-order-mobile"?: true; } }