@01.software/cli 0.17.0 → 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 +200 -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,7 +1979,75 @@ var confirmTossPaymentSessionBodySchema = z5.object({
|
|
|
1891
1979
|
var confirmTossPaymentSessionParamsSchema = confirmTossPaymentSessionBodySchema.extend({
|
|
1892
1980
|
idempotencyKey: commerceIdempotencyKeySchema
|
|
1893
1981
|
});
|
|
1894
|
-
var
|
|
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);
|
|
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");
|
|
1997
|
+
var customPaymentIdentitySchema = z5.string().trim().min(1);
|
|
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());
|
|
1999
|
+
var createCustomPaymentSessionBodySchema = z5.object({
|
|
2000
|
+
provider: customPaymentProviderSchema,
|
|
2001
|
+
checkoutToken: commerceCapabilitySchema
|
|
2002
|
+
}).strict();
|
|
2003
|
+
var createCustomPaymentSessionParamsSchema = createCustomPaymentSessionBodySchema.extend({
|
|
2004
|
+
idempotencyKey: commerceIdempotencyKeySchema
|
|
2005
|
+
});
|
|
2006
|
+
var customPaymentSessionSchema = z5.object({
|
|
2007
|
+
id: commerceResourceIdSchema,
|
|
2008
|
+
provider: customPaymentProviderSchema,
|
|
2009
|
+
providerSessionId: customPaymentIdentitySchema,
|
|
2010
|
+
money: moneySchema
|
|
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();
|
|
2035
|
+
var confirmCustomPaymentSessionBodySchema = z5.object({
|
|
2036
|
+
provider: customPaymentProviderSchema,
|
|
2037
|
+
providerSessionId: customPaymentIdentitySchema,
|
|
2038
|
+
providerPaymentId: customPaymentIdentitySchema,
|
|
2039
|
+
providerEventId: customPaymentIdentitySchema,
|
|
2040
|
+
amount: z5.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
2041
|
+
currency: customPaymentCurrencyInputSchema,
|
|
2042
|
+
occurredAt: customPaymentIdentitySchema
|
|
2043
|
+
}).strict();
|
|
2044
|
+
var confirmCustomPaymentSessionResponseSchema = z5.object({
|
|
2045
|
+
orderId: commerceResourceIdSchema,
|
|
2046
|
+
transactionId: commerceResourceIdSchema,
|
|
2047
|
+
status: z5.literal("paid"),
|
|
2048
|
+
alreadyConfirmed: z5.boolean().optional()
|
|
2049
|
+
}).strict();
|
|
2050
|
+
var tossPaymentNextActionSchema = z5.object({
|
|
1895
2051
|
type: z5.literal("toss_widget"),
|
|
1896
2052
|
clientKey: z5.string().min(1).max(255),
|
|
1897
2053
|
paymentMethodVariantKey: z5.string().min(1).max(255),
|
|
@@ -1902,6 +2058,17 @@ var paymentNextActionSchema = z5.object({
|
|
|
1902
2058
|
customerName: z5.string().min(1).max(200).optional(),
|
|
1903
2059
|
customerEmail: z5.string().email().max(254).optional()
|
|
1904
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
|
+
]);
|
|
1905
2072
|
var PAYMENT_SESSION_ROLES = [
|
|
1906
2073
|
"active",
|
|
1907
2074
|
"canonical_candidate",
|
|
@@ -1910,20 +2077,6 @@ var PAYMENT_SESSION_ROLES = [
|
|
|
1910
2077
|
"historical"
|
|
1911
2078
|
];
|
|
1912
2079
|
var paymentSessionRoleSchema = z5.enum(PAYMENT_SESSION_ROLES);
|
|
1913
|
-
var PAYMENT_PROVIDER_STATUSES = [
|
|
1914
|
-
"requires_payment_method",
|
|
1915
|
-
"requires_action",
|
|
1916
|
-
"requires_confirmation",
|
|
1917
|
-
"initializing",
|
|
1918
|
-
"processing",
|
|
1919
|
-
"authorized",
|
|
1920
|
-
"canceling",
|
|
1921
|
-
"unknown",
|
|
1922
|
-
"captured",
|
|
1923
|
-
"failed",
|
|
1924
|
-
"canceled"
|
|
1925
|
-
];
|
|
1926
|
-
var paymentProviderStatusSchema = z5.enum(PAYMENT_PROVIDER_STATUSES);
|
|
1927
2080
|
var PAYMENT_RECONCILIATION_REASONS = [
|
|
1928
2081
|
"provider_outcome_unknown",
|
|
1929
2082
|
"local_commit_ambiguous",
|
|
@@ -2113,17 +2266,18 @@ function stateSchemas(nextAction) {
|
|
|
2113
2266
|
})
|
|
2114
2267
|
];
|
|
2115
2268
|
}
|
|
2116
|
-
function providerSessionSchemas(action) {
|
|
2269
|
+
function providerSessionSchemas(provider, action) {
|
|
2117
2270
|
return stateSchemas(action).map(
|
|
2118
2271
|
(state) => z5.object({
|
|
2119
2272
|
...paymentSessionBaseShape,
|
|
2120
|
-
provider: z5.literal(
|
|
2273
|
+
provider: z5.literal(provider),
|
|
2121
2274
|
...state.shape
|
|
2122
2275
|
}).strict()
|
|
2123
2276
|
);
|
|
2124
2277
|
}
|
|
2125
2278
|
var publicPaymentSessionVariants = [
|
|
2126
|
-
...providerSessionSchemas(
|
|
2279
|
+
...providerSessionSchemas("toss", tossPaymentNextActionSchema),
|
|
2280
|
+
...providerSessionSchemas("portone", portOnePaymentNextActionSchema)
|
|
2127
2281
|
];
|
|
2128
2282
|
var publicPaymentSessionSchema = z5.union(publicPaymentSessionVariants);
|
|
2129
2283
|
var CreatePaymentSessionParamsSchema = createPaymentSessionParamsSchema;
|
|
@@ -3088,6 +3242,10 @@ function registerStockCommands(program2, getClient2, getFormat2) {
|
|
|
3088
3242
|
}
|
|
3089
3243
|
|
|
3090
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
|
+
}
|
|
3091
3249
|
function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
3092
3250
|
const checkout = program2.command("checkout").description("Checkout management");
|
|
3093
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) => {
|
|
@@ -3149,20 +3307,23 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3149
3307
|
);
|
|
3150
3308
|
return;
|
|
3151
3309
|
}
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
);
|
|
3310
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3311
|
+
const result = data.provider === "portone" ? await paymentSessions.createPortOne(data) : await paymentSessions.create(data);
|
|
3312
|
+
printResult(result, getFormat2());
|
|
3156
3313
|
} catch (error) {
|
|
3157
3314
|
exitWithError(error);
|
|
3158
3315
|
}
|
|
3159
3316
|
});
|
|
3160
|
-
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) => {
|
|
3161
3322
|
try {
|
|
3323
|
+
const provider = paymentProvider(opts.provider);
|
|
3324
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3162
3325
|
printResult(
|
|
3163
|
-
await
|
|
3164
|
-
paymentSessionId
|
|
3165
|
-
}),
|
|
3326
|
+
provider === "portone" ? await paymentSessions.retrievePortOne({ paymentSessionId }) : await paymentSessions.retrieve({ paymentSessionId }),
|
|
3166
3327
|
getFormat2()
|
|
3167
3328
|
);
|
|
3168
3329
|
} catch (error) {
|
|
@@ -3172,6 +3333,10 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3172
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(
|
|
3173
3334
|
"--data-file <path>",
|
|
3174
3335
|
"Read session ID and idempotency key from file"
|
|
3336
|
+
).option(
|
|
3337
|
+
"--provider <provider>",
|
|
3338
|
+
"Payment provider (toss or portone)",
|
|
3339
|
+
"toss"
|
|
3175
3340
|
).option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
3176
3341
|
try {
|
|
3177
3342
|
const data = parseWithSchema(
|
|
@@ -3179,6 +3344,7 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3179
3344
|
"payment-session cancel",
|
|
3180
3345
|
CancelServerPaymentSessionParamsSchema
|
|
3181
3346
|
);
|
|
3347
|
+
const provider = paymentProvider(opts.provider);
|
|
3182
3348
|
if (opts.dryRun) {
|
|
3183
3349
|
printResult(
|
|
3184
3350
|
sensitiveDryRunResult("payment-session cancel"),
|
|
@@ -3186,8 +3352,9 @@ function registerCommerceSessionCommands(program2, getClient2, getFormat2) {
|
|
|
3186
3352
|
);
|
|
3187
3353
|
return;
|
|
3188
3354
|
}
|
|
3355
|
+
const paymentSessions = getClient2().commerce.paymentSessions;
|
|
3189
3356
|
printResult(
|
|
3190
|
-
await
|
|
3357
|
+
provider === "portone" ? await paymentSessions.cancelPortOne(data) : await paymentSessions.cancel(data),
|
|
3191
3358
|
getFormat2()
|
|
3192
3359
|
);
|
|
3193
3360
|
} catch (error) {
|
|
@@ -3353,7 +3520,7 @@ import { randomBytes as randomBytes2 } from "crypto";
|
|
|
3353
3520
|
import { createServer } from "http";
|
|
3354
3521
|
import { execFile, exec } from "child_process";
|
|
3355
3522
|
import { platform } from "os";
|
|
3356
|
-
import { URL } from "url";
|
|
3523
|
+
import { URL as URL2 } from "url";
|
|
3357
3524
|
import pc2 from "picocolors";
|
|
3358
3525
|
var WEB_URL = process.env.SOFTWARE_WEB_URL || "https://01.software";
|
|
3359
3526
|
var TIMEOUT_MS = 3 * 60 * 1e3;
|
|
@@ -3446,7 +3613,7 @@ function startAuthServer(options) {
|
|
|
3446
3613
|
res.writeHead(400).end();
|
|
3447
3614
|
return;
|
|
3448
3615
|
}
|
|
3449
|
-
const url = new
|
|
3616
|
+
const url = new URL2(req.url, `http://localhost`);
|
|
3450
3617
|
if (url.pathname !== "/callback" || req.method !== "GET") {
|
|
3451
3618
|
res.writeHead(404).end();
|
|
3452
3619
|
return;
|