@01.software/cli 0.17.1 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +169 -33
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1104,6 +1104,17 @@ function registerCrudCommands(program2, getClient2, getFormat2) {
|
|
|
1104
1104
|
|
|
1105
1105
|
// ../../internal/contracts/src/tenant/index.ts
|
|
1106
1106
|
import { z } from "zod";
|
|
1107
|
+
|
|
1108
|
+
// ../../internal/contracts/src/tenant/features.ts
|
|
1109
|
+
var TENANT_CUSTOM_FIELD_TYPES = [
|
|
1110
|
+
"text",
|
|
1111
|
+
"number",
|
|
1112
|
+
"select",
|
|
1113
|
+
"boolean",
|
|
1114
|
+
"date"
|
|
1115
|
+
];
|
|
1116
|
+
|
|
1117
|
+
// ../../internal/contracts/src/tenant/index.ts
|
|
1107
1118
|
var tenantFieldConfigStateSchema = z.object({
|
|
1108
1119
|
hiddenFields: z.array(z.string()),
|
|
1109
1120
|
isHidden: z.boolean()
|
|
@@ -1218,6 +1229,29 @@ var collectionFieldOptionSchema = z.object({
|
|
|
1218
1229
|
label: z.string(),
|
|
1219
1230
|
value: z.string()
|
|
1220
1231
|
}).strict();
|
|
1232
|
+
var collectionCustomFieldRequiredSchema = z.literal(true).optional();
|
|
1233
|
+
var collectionCustomFieldDefinitionSchema = z.discriminatedUnion(
|
|
1234
|
+
"type",
|
|
1235
|
+
[
|
|
1236
|
+
z.object({
|
|
1237
|
+
key: z.string().min(1),
|
|
1238
|
+
type: z.enum(
|
|
1239
|
+
TENANT_CUSTOM_FIELD_TYPES.filter((type) => type !== "select")
|
|
1240
|
+
),
|
|
1241
|
+
required: collectionCustomFieldRequiredSchema
|
|
1242
|
+
}).strict(),
|
|
1243
|
+
z.object({
|
|
1244
|
+
key: z.string().min(1),
|
|
1245
|
+
type: z.literal("select"),
|
|
1246
|
+
required: collectionCustomFieldRequiredSchema,
|
|
1247
|
+
options: z.array(z.string().min(1)).min(1)
|
|
1248
|
+
}).strict()
|
|
1249
|
+
]
|
|
1250
|
+
);
|
|
1251
|
+
var collectionCustomFieldsSchema = z.object({
|
|
1252
|
+
storagePath: z.literal("customData"),
|
|
1253
|
+
definitions: z.array(collectionCustomFieldDefinitionSchema)
|
|
1254
|
+
}).strict();
|
|
1221
1255
|
var collectionFieldSchema = z.lazy(
|
|
1222
1256
|
() => z.object({
|
|
1223
1257
|
name: z.string(),
|
|
@@ -1247,7 +1281,8 @@ var collectionSchemaResponseSchema = z.object({
|
|
|
1247
1281
|
collectionHidden: z.boolean(),
|
|
1248
1282
|
hiddenFields: z.array(z.string())
|
|
1249
1283
|
}).strict(),
|
|
1250
|
-
fields: z.array(collectionFieldSchema)
|
|
1284
|
+
fields: z.array(collectionFieldSchema),
|
|
1285
|
+
customFields: collectionCustomFieldsSchema.optional()
|
|
1251
1286
|
}).strict()
|
|
1252
1287
|
}).strict();
|
|
1253
1288
|
|
|
@@ -1855,9 +1890,62 @@ var createTossPaymentSessionBodySchema = z5.object({
|
|
|
1855
1890
|
provider: z5.literal("toss"),
|
|
1856
1891
|
providerOptions: z5.object({ profile: z5.literal("widget_v2") }).strict()
|
|
1857
1892
|
}).strict();
|
|
1858
|
-
var
|
|
1859
|
-
|
|
1860
|
-
|
|
1893
|
+
var PORTONE_HOSTED_PAYMENT_METHODS = [
|
|
1894
|
+
"CARD_KR",
|
|
1895
|
+
"N_PAY",
|
|
1896
|
+
"KAKAO_PAY",
|
|
1897
|
+
"TOSS_PAY",
|
|
1898
|
+
"CARD_INTERNATIONAL",
|
|
1899
|
+
"PAY_PAL",
|
|
1900
|
+
"UNION_PAY",
|
|
1901
|
+
"ALIPAY_CN",
|
|
1902
|
+
"ALIPAY_HK",
|
|
1903
|
+
"TRUE_MONEY",
|
|
1904
|
+
"DANA",
|
|
1905
|
+
"TOUCH_N_GO",
|
|
1906
|
+
"G_CASH",
|
|
1907
|
+
"WE_CHAT_PAY",
|
|
1908
|
+
"KLARNA",
|
|
1909
|
+
"E_CONTEXT",
|
|
1910
|
+
"GRAB_PAY_MY",
|
|
1911
|
+
"GRAB_PAY_SG",
|
|
1912
|
+
"SHOPEE_PAY_TH",
|
|
1913
|
+
"PAY_PAY",
|
|
1914
|
+
"BPI",
|
|
1915
|
+
"RABBIT_LINE_PAY",
|
|
1916
|
+
"CONVENIENCE_STORE_JP",
|
|
1917
|
+
"AMAZON_PAY",
|
|
1918
|
+
"RAKUTEN_PAY",
|
|
1919
|
+
"D_BARAI",
|
|
1920
|
+
"AU_PAY",
|
|
1921
|
+
"MERPAY"
|
|
1922
|
+
];
|
|
1923
|
+
var portOneHostedPaymentMethodSchema = z5.enum(
|
|
1924
|
+
PORTONE_HOSTED_PAYMENT_METHODS
|
|
1925
|
+
);
|
|
1926
|
+
var createPortOnePaymentSessionBodySchema = z5.object({
|
|
1927
|
+
...createPaymentSessionBaseBodyShape,
|
|
1928
|
+
provider: z5.literal("portone"),
|
|
1929
|
+
providerOptions: z5.object({
|
|
1930
|
+
profile: z5.literal("hosted_v2"),
|
|
1931
|
+
paymentMethod: portOneHostedPaymentMethodSchema
|
|
1932
|
+
}).strict()
|
|
1933
|
+
}).strict();
|
|
1934
|
+
var createPaymentSessionBodySchema = z5.discriminatedUnion("provider", [
|
|
1935
|
+
createTossPaymentSessionBodySchema,
|
|
1936
|
+
createPortOnePaymentSessionBodySchema
|
|
1937
|
+
]);
|
|
1938
|
+
var createPaymentSessionParamsSchema = z5.discriminatedUnion(
|
|
1939
|
+
"provider",
|
|
1940
|
+
[
|
|
1941
|
+
createTossPaymentSessionBodySchema.extend({
|
|
1942
|
+
idempotencyKey: commerceIdempotencyKeySchema
|
|
1943
|
+
}),
|
|
1944
|
+
createPortOnePaymentSessionBodySchema.extend({
|
|
1945
|
+
idempotencyKey: commerceIdempotencyKeySchema
|
|
1946
|
+
})
|
|
1947
|
+
]
|
|
1948
|
+
);
|
|
1861
1949
|
var retrieveBrowserPaymentSessionParamsSchema = z5.object({
|
|
1862
1950
|
paymentSessionId: commerceResourceIdSchema,
|
|
1863
1951
|
checkoutToken: commerceCapabilitySchema
|
|
@@ -1891,6 +1979,20 @@ var confirmTossPaymentSessionBodySchema = z5.object({
|
|
|
1891
1979
|
var confirmTossPaymentSessionParamsSchema = confirmTossPaymentSessionBodySchema.extend({
|
|
1892
1980
|
idempotencyKey: commerceIdempotencyKeySchema
|
|
1893
1981
|
});
|
|
1982
|
+
var PAYMENT_PROVIDER_STATUSES = [
|
|
1983
|
+
"requires_payment_method",
|
|
1984
|
+
"requires_action",
|
|
1985
|
+
"requires_confirmation",
|
|
1986
|
+
"initializing",
|
|
1987
|
+
"processing",
|
|
1988
|
+
"authorized",
|
|
1989
|
+
"canceling",
|
|
1990
|
+
"unknown",
|
|
1991
|
+
"captured",
|
|
1992
|
+
"failed",
|
|
1993
|
+
"canceled"
|
|
1994
|
+
];
|
|
1995
|
+
var paymentProviderStatusSchema = z5.enum(PAYMENT_PROVIDER_STATUSES);
|
|
1894
1996
|
var customPaymentProviderSchema = z5.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]{0,63}$/i, "provider must be a slug");
|
|
1895
1997
|
var customPaymentIdentitySchema = z5.string().trim().min(1);
|
|
1896
1998
|
var customPaymentCurrencyInputSchema = z5.string().trim().min(1).regex(/^[A-Za-z]{3}$/, "currency must be a three-letter ISO 4217 code").transform((currency) => currency.toUpperCase());
|
|
@@ -1907,6 +2009,29 @@ var customPaymentSessionSchema = z5.object({
|
|
|
1907
2009
|
providerSessionId: customPaymentIdentitySchema,
|
|
1908
2010
|
money: moneySchema
|
|
1909
2011
|
}).strict();
|
|
2012
|
+
var customPaymentSessionLookupSchema = z5.union([
|
|
2013
|
+
z5.object({
|
|
2014
|
+
providerSessionId: customPaymentIdentitySchema
|
|
2015
|
+
}).strict(),
|
|
2016
|
+
z5.object({
|
|
2017
|
+
providerPaymentId: customPaymentIdentitySchema
|
|
2018
|
+
}).strict()
|
|
2019
|
+
]);
|
|
2020
|
+
var retrieveCustomPaymentSessionBodySchema = z5.object({
|
|
2021
|
+
provider: customPaymentProviderSchema,
|
|
2022
|
+
by: customPaymentSessionLookupSchema
|
|
2023
|
+
}).strict();
|
|
2024
|
+
var retrievedCustomPaymentSessionSchema = z5.object({
|
|
2025
|
+
id: commerceResourceIdSchema,
|
|
2026
|
+
provider: customPaymentProviderSchema,
|
|
2027
|
+
providerSessionId: customPaymentIdentitySchema,
|
|
2028
|
+
providerPaymentId: customPaymentIdentitySchema.nullable(),
|
|
2029
|
+
status: z5.enum(["pending", "captured", "failed", "canceled"]),
|
|
2030
|
+
providerStatus: paymentProviderStatusSchema,
|
|
2031
|
+
finalizationStatus: z5.enum(["not_ready", "pending", "committed"]),
|
|
2032
|
+
money: moneySchema,
|
|
2033
|
+
orderId: commerceResourceIdSchema.nullable()
|
|
2034
|
+
}).strict();
|
|
1910
2035
|
var confirmCustomPaymentSessionBodySchema = z5.object({
|
|
1911
2036
|
provider: customPaymentProviderSchema,
|
|
1912
2037
|
providerSessionId: customPaymentIdentitySchema,
|
|
@@ -1922,7 +2047,7 @@ var confirmCustomPaymentSessionResponseSchema = z5.object({
|
|
|
1922
2047
|
status: z5.literal("paid"),
|
|
1923
2048
|
alreadyConfirmed: z5.boolean().optional()
|
|
1924
2049
|
}).strict();
|
|
1925
|
-
var
|
|
2050
|
+
var tossPaymentNextActionSchema = z5.object({
|
|
1926
2051
|
type: z5.literal("toss_widget"),
|
|
1927
2052
|
clientKey: z5.string().min(1).max(255),
|
|
1928
2053
|
paymentMethodVariantKey: z5.string().min(1).max(255),
|
|
@@ -1933,6 +2058,17 @@ var paymentNextActionSchema = z5.object({
|
|
|
1933
2058
|
customerName: z5.string().min(1).max(200).optional(),
|
|
1934
2059
|
customerEmail: z5.string().email().max(254).optional()
|
|
1935
2060
|
}).strict();
|
|
2061
|
+
var portOnePaymentNextActionSchema = z5.object({
|
|
2062
|
+
type: z5.literal("portone_checkout"),
|
|
2063
|
+
checkoutUrl: z5.string().url().startsWith("https://").max(2048).refine((value) => {
|
|
2064
|
+
const url = new URL(value);
|
|
2065
|
+
return url.username === "" && url.password === "";
|
|
2066
|
+
}, "checkoutUrl must not contain embedded credentials")
|
|
2067
|
+
}).strict();
|
|
2068
|
+
var paymentNextActionSchema = z5.discriminatedUnion("type", [
|
|
2069
|
+
tossPaymentNextActionSchema,
|
|
2070
|
+
portOnePaymentNextActionSchema
|
|
2071
|
+
]);
|
|
1936
2072
|
var PAYMENT_SESSION_ROLES = [
|
|
1937
2073
|
"active",
|
|
1938
2074
|
"canonical_candidate",
|
|
@@ -1941,20 +2077,6 @@ var PAYMENT_SESSION_ROLES = [
|
|
|
1941
2077
|
"historical"
|
|
1942
2078
|
];
|
|
1943
2079
|
var paymentSessionRoleSchema = z5.enum(PAYMENT_SESSION_ROLES);
|
|
1944
|
-
var PAYMENT_PROVIDER_STATUSES = [
|
|
1945
|
-
"requires_payment_method",
|
|
1946
|
-
"requires_action",
|
|
1947
|
-
"requires_confirmation",
|
|
1948
|
-
"initializing",
|
|
1949
|
-
"processing",
|
|
1950
|
-
"authorized",
|
|
1951
|
-
"canceling",
|
|
1952
|
-
"unknown",
|
|
1953
|
-
"captured",
|
|
1954
|
-
"failed",
|
|
1955
|
-
"canceled"
|
|
1956
|
-
];
|
|
1957
|
-
var paymentProviderStatusSchema = z5.enum(PAYMENT_PROVIDER_STATUSES);
|
|
1958
2080
|
var PAYMENT_RECONCILIATION_REASONS = [
|
|
1959
2081
|
"provider_outcome_unknown",
|
|
1960
2082
|
"local_commit_ambiguous",
|
|
@@ -2144,17 +2266,18 @@ function stateSchemas(nextAction) {
|
|
|
2144
2266
|
})
|
|
2145
2267
|
];
|
|
2146
2268
|
}
|
|
2147
|
-
function providerSessionSchemas(action) {
|
|
2269
|
+
function providerSessionSchemas(provider, action) {
|
|
2148
2270
|
return stateSchemas(action).map(
|
|
2149
2271
|
(state) => z5.object({
|
|
2150
2272
|
...paymentSessionBaseShape,
|
|
2151
|
-
provider: z5.literal(
|
|
2273
|
+
provider: z5.literal(provider),
|
|
2152
2274
|
...state.shape
|
|
2153
2275
|
}).strict()
|
|
2154
2276
|
);
|
|
2155
2277
|
}
|
|
2156
2278
|
var publicPaymentSessionVariants = [
|
|
2157
|
-
...providerSessionSchemas(
|
|
2279
|
+
...providerSessionSchemas("toss", tossPaymentNextActionSchema),
|
|
2280
|
+
...providerSessionSchemas("portone", portOnePaymentNextActionSchema)
|
|
2158
2281
|
];
|
|
2159
2282
|
var publicPaymentSessionSchema = z5.union(publicPaymentSessionVariants);
|
|
2160
2283
|
var CreatePaymentSessionParamsSchema = createPaymentSessionParamsSchema;
|
|
@@ -3119,6 +3242,10 @@ function registerStockCommands(program2, getClient2, getFormat2) {
|
|
|
3119
3242
|
}
|
|
3120
3243
|
|
|
3121
3244
|
// src/commands/transaction.ts
|
|
3245
|
+
function paymentProvider(value) {
|
|
3246
|
+
if (value === "toss" || value === "portone") return value;
|
|
3247
|
+
throw new Error("payment provider must be toss or portone");
|
|
3248
|
+
}
|
|
3122
3249
|
function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
3123
3250
|
const checkout = program2.command("checkout").description("Checkout management");
|
|
3124
3251
|
checkout.command("create").description("Create a Checkout from a server-authoritative Cart").option("--data-stdin", "Read capability and customer JSON from stdin").option("--data-file <path>", "Read capability and customer JSON from file").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
@@ -3180,20 +3307,23 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3180
3307
|
);
|
|
3181
3308
|
return;
|
|
3182
3309
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
);
|
|
3310
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3311
|
+
const result = data.provider === "portone" ? await paymentSessions.createPortOne(data) : await paymentSessions.create(data);
|
|
3312
|
+
printResult(result, getFormat2());
|
|
3187
3313
|
} catch (error) {
|
|
3188
3314
|
exitWithError(error);
|
|
3189
3315
|
}
|
|
3190
3316
|
});
|
|
3191
|
-
sessions.command("retrieve <paymentSessionId>").description("Retrieve a PaymentSession").
|
|
3317
|
+
sessions.command("retrieve <paymentSessionId>").description("Retrieve a PaymentSession").option(
|
|
3318
|
+
"--provider <provider>",
|
|
3319
|
+
"Payment provider (toss or portone)",
|
|
3320
|
+
"toss"
|
|
3321
|
+
).action(async (paymentSessionId, opts) => {
|
|
3192
3322
|
try {
|
|
3323
|
+
const provider = paymentProvider(opts.provider);
|
|
3324
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3193
3325
|
printResult(
|
|
3194
|
-
await
|
|
3195
|
-
paymentSessionId
|
|
3196
|
-
}),
|
|
3326
|
+
provider === "portone" ? await paymentSessions.retrievePortOne({ paymentSessionId }) : await paymentSessions.retrieve({ paymentSessionId }),
|
|
3197
3327
|
getFormat2()
|
|
3198
3328
|
);
|
|
3199
3329
|
} catch (error) {
|
|
@@ -3203,6 +3333,10 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3203
3333
|
sessions.command("cancel").description("Cancel a PaymentSession and release its payment slot").option("--data-stdin", "Read session ID and idempotency key from stdin").option(
|
|
3204
3334
|
"--data-file <path>",
|
|
3205
3335
|
"Read session ID and idempotency key from file"
|
|
3336
|
+
).option(
|
|
3337
|
+
"--provider <provider>",
|
|
3338
|
+
"Payment provider (toss or portone)",
|
|
3339
|
+
"toss"
|
|
3206
3340
|
).option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
3207
3341
|
try {
|
|
3208
3342
|
const data = parseWithSchema(
|
|
@@ -3210,6 +3344,7 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3210
3344
|
"payment-session cancel",
|
|
3211
3345
|
CancelServerPaymentSessionParamsSchema
|
|
3212
3346
|
);
|
|
3347
|
+
const provider = paymentProvider(opts.provider);
|
|
3213
3348
|
if (opts.dryRun) {
|
|
3214
3349
|
printResult(
|
|
3215
3350
|
sensitiveDryRunResult("payment-session cancel"),
|
|
@@ -3217,8 +3352,9 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3217
3352
|
);
|
|
3218
3353
|
return;
|
|
3219
3354
|
}
|
|
3355
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3220
3356
|
printResult(
|
|
3221
|
-
await
|
|
3357
|
+
provider === "portone" ? await paymentSessions.cancelPortOne(data) : await paymentSessions.cancel(data),
|
|
3222
3358
|
getFormat2()
|
|
3223
3359
|
);
|
|
3224
3360
|
} catch (error) {
|
|
@@ -3384,7 +3520,7 @@ import { randomBytes as randomBytes2 } from "crypto";
|
|
|
3384
3520
|
import { createServer } from "http";
|
|
3385
3521
|
import { execFile, exec } from "child_process";
|
|
3386
3522
|
import { platform } from "os";
|
|
3387
|
-
import { URL } from "url";
|
|
3523
|
+
import { URL as URL2 } from "url";
|
|
3388
3524
|
import pc2 from "picocolors";
|
|
3389
3525
|
var WEB_URL = process.env.SOFTWARE_WEB_URL || "https://01.software";
|
|
3390
3526
|
var TIMEOUT_MS = 3 * 60 * 1e3;
|
|
@@ -3477,7 +3613,7 @@ function startAuthServer(options) {
|
|
|
3477
3613
|
res.writeHead(400).end();
|
|
3478
3614
|
return;
|
|
3479
3615
|
}
|
|
3480
|
-
const url = new
|
|
3616
|
+
const url = new URL2(req.url, `http://localhost`);
|
|
3481
3617
|
if (url.pathname !== "/callback" || req.method !== "GET") {
|
|
3482
3618
|
res.writeHead(404).end();
|
|
3483
3619
|
return;
|