@pome-sh/cli 0.21.13 → 0.21.14
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/build-info.json +3 -3
- package/dist/{checks-MM2OJJES.js → checks-6E6OKTHQ.js} +1 -1
- package/dist/chunk-4MQULI7E.js +427 -0
- package/dist/{chunk-BV35ZSB6.js → chunk-BTDWCUMP.js} +10 -10
- package/dist/{chunk-M7HRXBVU.js → chunk-DSQNW2ZT.js} +2 -2
- package/dist/{chunk-2TSYKRER.js → chunk-LKN7DYCG.js} +1 -1
- package/dist/{chunk-UCLRWEKB.js → chunk-P6RAEIIU.js} +1 -1
- package/dist/{chunk-CC27LWIA.js → chunk-TIY2TZAD.js} +1 -1
- package/dist/{runDemo-4ASIOIMV.js → runDemo-JPIZBQ2W.js} +4 -4
- package/dist/{runTrialGroup-UQKE6XQF.js → runTrialGroup-JHZ4LPKF.js} +3 -3
- package/dist/src/cli/main.js +12 -12
- package/dist/{src-YH33B2LP.js → src-566DJYOC.js} +441 -339
- package/dist/{src-JWB5RQSN.js → src-EAA6L4CV.js} +137 -42
- package/dist/{src-5RPY72NF.js → src-GIKWIJM2.js} +719 -269
- package/dist/{src-RUUCDQU4.js → src-MX3THU4R.js} +369 -193
- package/dist/{src-B63VPRRZ.js → src-WS5PCGRC.js} +647 -431
- package/dist/twinHarness-AHRNZB6Y.js +5 -0
- package/dist/{twinStart-TTVUZ7PC.js → twinStart-4EYV577J.js} +2 -2
- package/package.json +1 -1
- package/dist/twinHarness-BHSSYAEG.js +0 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bracketedQuery, integerInput, booleanInput, declareRouteInputs, mountDeclaredRoute, UndeclaredInputError } from './chunk-4MQULI7E.js';
|
|
1
2
|
import { failureInjectionRuleSchema, loadMcpToolFixture, openTwinDatabase, createFailureInjectionStore, defineTwin, twinBuildInfo, deriveMcpToolTable, failureInjectionMiddleware, createApp, FAILURE_INJECTION_OVERRIDE_KEY, recordedRequestHeaders, UnknownToolError } from './chunk-TV5S6WQV.js';
|
|
2
3
|
import './chunk-VBATFCWR.js';
|
|
3
4
|
import './chunk-SG6ZTIMT.js';
|
|
@@ -2742,406 +2743,507 @@ function errorMessage(body) {
|
|
|
2742
2743
|
}
|
|
2743
2744
|
return "request failed";
|
|
2744
2745
|
}
|
|
2745
|
-
function
|
|
2746
|
-
|
|
2747
|
-
const numericLimit = limit !== void 0 ? Number(limit) : void 0;
|
|
2748
|
-
const created2 = createdRangeFromQuery(c);
|
|
2749
|
-
return {
|
|
2750
|
-
limit: Number.isFinite(numericLimit) ? numericLimit : void 0,
|
|
2751
|
-
starting_after: c.req.query("starting_after"),
|
|
2752
|
-
ending_before: c.req.query("ending_before"),
|
|
2753
|
-
...created2
|
|
2754
|
-
};
|
|
2746
|
+
function declaredRoute(router, declaration, recorder, runId, fn) {
|
|
2747
|
+
mountDeclaredRoute(router, declaration, (c) => handle(c, recorder, runId, async () => fn(await parseDeclared(declaration, c), c)));
|
|
2755
2748
|
}
|
|
2756
|
-
async function
|
|
2757
|
-
const contentType = c.req.header("content-type") ?? "";
|
|
2758
|
-
if (contentType.includes("application/json")) {
|
|
2759
|
-
try {
|
|
2760
|
-
return await c.req.json();
|
|
2761
|
-
} catch {
|
|
2762
|
-
return {};
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
if (contentType.includes("application/x-www-form-urlencoded") || contentType.includes("multipart/form-data")) {
|
|
2766
|
-
try {
|
|
2767
|
-
const form = await c.req.parseBody({ all: true });
|
|
2768
|
-
return formToObject(form);
|
|
2769
|
-
} catch {
|
|
2770
|
-
return {};
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2749
|
+
async function parseDeclared(declaration, c) {
|
|
2773
2750
|
try {
|
|
2774
|
-
return await c.req
|
|
2775
|
-
} catch {
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
return formToObject(form);
|
|
2779
|
-
} catch {
|
|
2780
|
-
return {};
|
|
2751
|
+
return await declaration.parse(c.req);
|
|
2752
|
+
} catch (error) {
|
|
2753
|
+
if (error instanceof UndeclaredInputError) {
|
|
2754
|
+
throw new TwinError("invalid_request_error", "parameter_unknown", `Received unknown parameter: ${error.first}`, { param: error.first, statusCode: 400 });
|
|
2781
2755
|
}
|
|
2756
|
+
throw error;
|
|
2782
2757
|
}
|
|
2783
2758
|
}
|
|
2784
|
-
function
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
}
|
|
2792
|
-
var POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
2793
|
-
function parseBracketPath(key) {
|
|
2794
|
-
const parts = [];
|
|
2795
|
-
const regex = /([^\[\]]+)|\[([^\[\]]*)\]/g;
|
|
2796
|
-
let match;
|
|
2797
|
-
while ((match = regex.exec(key)) !== null) {
|
|
2798
|
-
const piece = match[1] ?? match[2] ?? "";
|
|
2799
|
-
if (/^\d+$/.test(piece))
|
|
2800
|
-
parts.push(Number(piece));
|
|
2801
|
-
else
|
|
2802
|
-
parts.push(piece);
|
|
2803
|
-
}
|
|
2804
|
-
return parts;
|
|
2805
|
-
}
|
|
2806
|
-
function setDeep(target, path, value) {
|
|
2807
|
-
for (const key of path) {
|
|
2808
|
-
if (typeof key === "string" && POLLUTION_KEYS.has(key)) {
|
|
2809
|
-
return;
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
let cursor = target;
|
|
2813
|
-
for (let i = 0; i < path.length; i++) {
|
|
2814
|
-
const key = path[i];
|
|
2815
|
-
const isLast = i === path.length - 1;
|
|
2816
|
-
if (isLast) {
|
|
2817
|
-
cursor[key] = value;
|
|
2818
|
-
} else {
|
|
2819
|
-
const nextKey = path[i + 1];
|
|
2820
|
-
if (cursor[key] === void 0) {
|
|
2821
|
-
cursor[key] = typeof nextKey === "number" ? [] : {};
|
|
2822
|
-
}
|
|
2823
|
-
cursor = cursor[key];
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2759
|
+
function listQuery(query) {
|
|
2760
|
+
return {
|
|
2761
|
+
limit: query.limit,
|
|
2762
|
+
starting_after: query.starting_after,
|
|
2763
|
+
ending_before: query.ending_before,
|
|
2764
|
+
...flattenCreated(query.created)
|
|
2765
|
+
};
|
|
2826
2766
|
}
|
|
2827
|
-
function
|
|
2767
|
+
function flattenCreated(created2) {
|
|
2828
2768
|
const out = {};
|
|
2829
|
-
|
|
2769
|
+
if (created2 === void 0)
|
|
2770
|
+
return out;
|
|
2771
|
+
const flat = typeof created2 === "string" ? created2 : created2.value;
|
|
2830
2772
|
if (flat !== void 0 && /^\d+$/.test(flat)) {
|
|
2831
2773
|
out.created_gte = Number(flat);
|
|
2832
2774
|
out.created_lte = Number(flat);
|
|
2833
2775
|
}
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
out.created_gte = Number(gte);
|
|
2842
|
-
if (lt && /^\d+$/.test(lt))
|
|
2843
|
-
out.created_lt = Number(lt);
|
|
2844
|
-
if (lte && /^\d+$/.test(lte))
|
|
2845
|
-
out.created_lte = Number(lte);
|
|
2776
|
+
if (typeof created2 === "string")
|
|
2777
|
+
return out;
|
|
2778
|
+
for (const op of ["gt", "gte", "lt", "lte"]) {
|
|
2779
|
+
const value = created2[op];
|
|
2780
|
+
if (value !== void 0 && /^\d+$/.test(value))
|
|
2781
|
+
out[`created_${op}`] = Number(value);
|
|
2782
|
+
}
|
|
2846
2783
|
return out;
|
|
2847
2784
|
}
|
|
2848
|
-
var
|
|
2849
|
-
var
|
|
2785
|
+
var ID_PATH = { id: z.string().min(1) };
|
|
2786
|
+
var LIST_QUERY = {
|
|
2787
|
+
limit: integerInput({ min: 1 }).optional(),
|
|
2788
|
+
starting_after: z.string().optional(),
|
|
2789
|
+
ending_before: z.string().optional(),
|
|
2790
|
+
created: bracketedQuery(z.union([z.string(), z.record(z.string(), z.string())]).optional())
|
|
2791
|
+
};
|
|
2792
|
+
var NULLABLE_METADATA = z.record(z.string(), z.string().nullable()).optional();
|
|
2793
|
+
var CREATE_PAYMENT_INTENT_BODY = {
|
|
2850
2794
|
amount: z.coerce.number().int().positive(),
|
|
2851
2795
|
currency: z.string().min(1),
|
|
2852
2796
|
payment_method_types: z.array(z.string()).min(1),
|
|
2853
2797
|
payment_method_options: z.object({
|
|
2854
2798
|
crypto: z.object({
|
|
2855
2799
|
mode: z.literal("deposit"),
|
|
2856
|
-
deposit_options: z.object({
|
|
2857
|
-
networks: z.array(z.string()).min(1).optional()
|
|
2858
|
-
}).optional()
|
|
2800
|
+
deposit_options: z.object({ networks: z.array(z.string()).min(1).optional() }).optional()
|
|
2859
2801
|
})
|
|
2860
2802
|
}).optional(),
|
|
2861
2803
|
payment_method: z.string().optional(),
|
|
2862
2804
|
customer: z.string().optional(),
|
|
2863
|
-
confirm:
|
|
2805
|
+
confirm: booleanInput.optional(),
|
|
2864
2806
|
metadata: z.record(z.string(), z.string()).optional(),
|
|
2865
2807
|
capture_method: z.string().optional(),
|
|
2866
2808
|
confirmation_method: z.string().optional()
|
|
2867
|
-
}
|
|
2868
|
-
var
|
|
2869
|
-
payment_method: z.string().optional()
|
|
2870
|
-
});
|
|
2871
|
-
var updatePISchema = z.object({
|
|
2809
|
+
};
|
|
2810
|
+
var UPDATE_PAYMENT_INTENT_BODY = {
|
|
2872
2811
|
amount: z.coerce.number().int().optional(),
|
|
2873
|
-
metadata:
|
|
2812
|
+
metadata: NULLABLE_METADATA,
|
|
2874
2813
|
payment_method: z.string().optional(),
|
|
2875
2814
|
customer: z.string().optional()
|
|
2876
|
-
}
|
|
2815
|
+
};
|
|
2816
|
+
var CONFIRM_PAYMENT_INTENT_BODY = { payment_method: z.string().optional() };
|
|
2817
|
+
var CREATE_REFUND_BODY = {
|
|
2818
|
+
charge: z.string().optional(),
|
|
2819
|
+
amount: z.coerce.number().optional(),
|
|
2820
|
+
reason: z.string().nullish()
|
|
2821
|
+
};
|
|
2822
|
+
var CUSTOMER_FIELDS_BODY = {
|
|
2823
|
+
name: z.string().nullish(),
|
|
2824
|
+
email: z.string().nullish(),
|
|
2825
|
+
description: z.string().nullish(),
|
|
2826
|
+
phone: z.string().nullish(),
|
|
2827
|
+
metadata: NULLABLE_METADATA
|
|
2828
|
+
};
|
|
2829
|
+
var CREATE_PAYMENT_METHOD_BODY = {
|
|
2830
|
+
type: z.unknown().optional(),
|
|
2831
|
+
card: z.unknown().optional()
|
|
2832
|
+
};
|
|
2833
|
+
var PRODUCT_FIELDS_BODY = {
|
|
2834
|
+
name: z.string().min(1).optional(),
|
|
2835
|
+
description: z.string().nullish(),
|
|
2836
|
+
active: booleanInput.optional(),
|
|
2837
|
+
metadata: NULLABLE_METADATA
|
|
2838
|
+
};
|
|
2839
|
+
var CREATE_PRICE_BODY = {
|
|
2840
|
+
currency: z.string().min(1).optional(),
|
|
2841
|
+
product: z.string().min(1).optional(),
|
|
2842
|
+
unit_amount: z.coerce.number().int().nonnegative().optional(),
|
|
2843
|
+
recurring: z.object({
|
|
2844
|
+
interval: z.string().min(1),
|
|
2845
|
+
interval_count: z.coerce.number().int().positive().optional()
|
|
2846
|
+
}).optional(),
|
|
2847
|
+
nickname: z.string().nullish(),
|
|
2848
|
+
lookup_key: z.string().nullish(),
|
|
2849
|
+
active: booleanInput.optional(),
|
|
2850
|
+
metadata: NULLABLE_METADATA
|
|
2851
|
+
};
|
|
2852
|
+
var CREATE_SUBSCRIPTION_BODY = {
|
|
2853
|
+
customer: z.string().min(1).optional(),
|
|
2854
|
+
items: z.array(z.object({
|
|
2855
|
+
price: z.string().min(1).optional(),
|
|
2856
|
+
quantity: z.coerce.number().int().positive().optional()
|
|
2857
|
+
})).optional(),
|
|
2858
|
+
cancel_at_period_end: booleanInput.optional(),
|
|
2859
|
+
metadata: NULLABLE_METADATA
|
|
2860
|
+
};
|
|
2861
|
+
var UPDATE_SUBSCRIPTION_BODY = {
|
|
2862
|
+
cancel_at_period_end: booleanInput.optional(),
|
|
2863
|
+
metadata: NULLABLE_METADATA
|
|
2864
|
+
};
|
|
2865
|
+
var STRIPE_ROUTES = {
|
|
2866
|
+
// ---------- PaymentIntents ----------
|
|
2867
|
+
createPaymentIntent: declareRouteInputs({
|
|
2868
|
+
method: "POST",
|
|
2869
|
+
path: "/v1/payment_intents",
|
|
2870
|
+
bodyEncoding: "form",
|
|
2871
|
+
body: CREATE_PAYMENT_INTENT_BODY
|
|
2872
|
+
}),
|
|
2873
|
+
retrievePaymentIntent: declareRouteInputs({
|
|
2874
|
+
method: "GET",
|
|
2875
|
+
path: "/v1/payment_intents/:id",
|
|
2876
|
+
pathParams: ID_PATH
|
|
2877
|
+
}),
|
|
2878
|
+
listPaymentIntents: declareRouteInputs({
|
|
2879
|
+
method: "GET",
|
|
2880
|
+
path: "/v1/payment_intents",
|
|
2881
|
+
query: LIST_QUERY
|
|
2882
|
+
}),
|
|
2883
|
+
confirmPaymentIntent: declareRouteInputs({
|
|
2884
|
+
method: "POST",
|
|
2885
|
+
path: "/v1/payment_intents/:id/confirm",
|
|
2886
|
+
pathParams: ID_PATH,
|
|
2887
|
+
bodyEncoding: "form",
|
|
2888
|
+
body: CONFIRM_PAYMENT_INTENT_BODY
|
|
2889
|
+
}),
|
|
2890
|
+
updatePaymentIntent: declareRouteInputs({
|
|
2891
|
+
method: "POST",
|
|
2892
|
+
path: "/v1/payment_intents/:id",
|
|
2893
|
+
pathParams: ID_PATH,
|
|
2894
|
+
bodyEncoding: "form",
|
|
2895
|
+
body: UPDATE_PAYMENT_INTENT_BODY
|
|
2896
|
+
}),
|
|
2897
|
+
// Cancellation takes no body at all here. Real Stripe accepts
|
|
2898
|
+
// `cancellation_reason`; this twin has never read it, so it is not declared.
|
|
2899
|
+
cancelPaymentIntent: declareRouteInputs({
|
|
2900
|
+
method: "POST",
|
|
2901
|
+
path: "/v1/payment_intents/:id/cancel",
|
|
2902
|
+
pathParams: ID_PATH
|
|
2903
|
+
}),
|
|
2904
|
+
simulateCryptoDeposit: declareRouteInputs({
|
|
2905
|
+
method: "POST",
|
|
2906
|
+
path: "/v1/test_helpers/payment_intents/:id/simulate_crypto_deposit",
|
|
2907
|
+
pathParams: ID_PATH
|
|
2908
|
+
}),
|
|
2909
|
+
// ---------- Charges ----------
|
|
2910
|
+
retrieveCharge: declareRouteInputs({
|
|
2911
|
+
method: "GET",
|
|
2912
|
+
path: "/v1/charges/:id",
|
|
2913
|
+
pathParams: ID_PATH
|
|
2914
|
+
}),
|
|
2915
|
+
listCharges: declareRouteInputs({
|
|
2916
|
+
method: "GET",
|
|
2917
|
+
path: "/v1/charges",
|
|
2918
|
+
query: { ...LIST_QUERY, payment_intent: z.string().optional(), customer: z.string().optional() }
|
|
2919
|
+
}),
|
|
2920
|
+
// ---------- Refunds ----------
|
|
2921
|
+
createRefund: declareRouteInputs({
|
|
2922
|
+
method: "POST",
|
|
2923
|
+
path: "/v1/refunds",
|
|
2924
|
+
// A real declared input on this route: the handler reads it and the domain
|
|
2925
|
+
// stores it on the refund. Undeclared headers are ignored rather than
|
|
2926
|
+
// refused, so the engine's own (`Authorization`, `Stripe-Account`) need no
|
|
2927
|
+
// entry here — they are not this route's inputs.
|
|
2928
|
+
headers: { "Idempotency-Key": z.string().optional() },
|
|
2929
|
+
bodyEncoding: "form",
|
|
2930
|
+
body: CREATE_REFUND_BODY
|
|
2931
|
+
}),
|
|
2932
|
+
retrieveRefund: declareRouteInputs({
|
|
2933
|
+
method: "GET",
|
|
2934
|
+
path: "/v1/refunds/:id",
|
|
2935
|
+
pathParams: ID_PATH
|
|
2936
|
+
}),
|
|
2937
|
+
listRefunds: declareRouteInputs({
|
|
2938
|
+
method: "GET",
|
|
2939
|
+
path: "/v1/refunds",
|
|
2940
|
+
query: { ...LIST_QUERY, charge: z.string().optional(), payment_intent: z.string().optional() }
|
|
2941
|
+
}),
|
|
2942
|
+
// ---------- Customers ----------
|
|
2943
|
+
createCustomer: declareRouteInputs({
|
|
2944
|
+
method: "POST",
|
|
2945
|
+
path: "/v1/customers",
|
|
2946
|
+
bodyEncoding: "form",
|
|
2947
|
+
body: CUSTOMER_FIELDS_BODY
|
|
2948
|
+
}),
|
|
2949
|
+
listCustomerPaymentMethods: declareRouteInputs({
|
|
2950
|
+
method: "GET",
|
|
2951
|
+
path: "/v1/customers/:id/payment_methods",
|
|
2952
|
+
pathParams: ID_PATH,
|
|
2953
|
+
query: { ...LIST_QUERY, type: z.string().optional() }
|
|
2954
|
+
}),
|
|
2955
|
+
retrieveCustomer: declareRouteInputs({
|
|
2956
|
+
method: "GET",
|
|
2957
|
+
path: "/v1/customers/:id",
|
|
2958
|
+
pathParams: ID_PATH
|
|
2959
|
+
}),
|
|
2960
|
+
updateCustomer: declareRouteInputs({
|
|
2961
|
+
method: "POST",
|
|
2962
|
+
path: "/v1/customers/:id",
|
|
2963
|
+
pathParams: ID_PATH,
|
|
2964
|
+
bodyEncoding: "form",
|
|
2965
|
+
body: CUSTOMER_FIELDS_BODY
|
|
2966
|
+
}),
|
|
2967
|
+
deleteCustomer: declareRouteInputs({
|
|
2968
|
+
method: "DELETE",
|
|
2969
|
+
path: "/v1/customers/:id",
|
|
2970
|
+
pathParams: ID_PATH
|
|
2971
|
+
}),
|
|
2972
|
+
listCustomers: declareRouteInputs({
|
|
2973
|
+
method: "GET",
|
|
2974
|
+
path: "/v1/customers",
|
|
2975
|
+
query: { ...LIST_QUERY, email: z.string().optional() }
|
|
2976
|
+
}),
|
|
2977
|
+
// ---------- Payment methods ----------
|
|
2978
|
+
createPaymentMethod: declareRouteInputs({
|
|
2979
|
+
method: "POST",
|
|
2980
|
+
path: "/v1/payment_methods",
|
|
2981
|
+
bodyEncoding: "form",
|
|
2982
|
+
body: CREATE_PAYMENT_METHOD_BODY
|
|
2983
|
+
}),
|
|
2984
|
+
retrievePaymentMethod: declareRouteInputs({
|
|
2985
|
+
method: "GET",
|
|
2986
|
+
path: "/v1/payment_methods/:id",
|
|
2987
|
+
pathParams: ID_PATH
|
|
2988
|
+
}),
|
|
2989
|
+
attachPaymentMethod: declareRouteInputs({
|
|
2990
|
+
method: "POST",
|
|
2991
|
+
path: "/v1/payment_methods/:id/attach",
|
|
2992
|
+
pathParams: ID_PATH,
|
|
2993
|
+
bodyEncoding: "form",
|
|
2994
|
+
body: { customer: z.string().optional() }
|
|
2995
|
+
}),
|
|
2996
|
+
detachPaymentMethod: declareRouteInputs({
|
|
2997
|
+
method: "POST",
|
|
2998
|
+
path: "/v1/payment_methods/:id/detach",
|
|
2999
|
+
pathParams: ID_PATH
|
|
3000
|
+
}),
|
|
3001
|
+
// ---------- Products ----------
|
|
3002
|
+
createProduct: declareRouteInputs({
|
|
3003
|
+
method: "POST",
|
|
3004
|
+
path: "/v1/products",
|
|
3005
|
+
bodyEncoding: "form",
|
|
3006
|
+
body: PRODUCT_FIELDS_BODY
|
|
3007
|
+
}),
|
|
3008
|
+
retrieveProduct: declareRouteInputs({
|
|
3009
|
+
method: "GET",
|
|
3010
|
+
path: "/v1/products/:id",
|
|
3011
|
+
pathParams: ID_PATH
|
|
3012
|
+
}),
|
|
3013
|
+
listProducts: declareRouteInputs({
|
|
3014
|
+
method: "GET",
|
|
3015
|
+
path: "/v1/products",
|
|
3016
|
+
query: { ...LIST_QUERY, active: booleanInput.optional() }
|
|
3017
|
+
}),
|
|
3018
|
+
// ---------- Prices ----------
|
|
3019
|
+
createPrice: declareRouteInputs({
|
|
3020
|
+
method: "POST",
|
|
3021
|
+
path: "/v1/prices",
|
|
3022
|
+
bodyEncoding: "form",
|
|
3023
|
+
body: CREATE_PRICE_BODY
|
|
3024
|
+
}),
|
|
3025
|
+
retrievePrice: declareRouteInputs({
|
|
3026
|
+
method: "GET",
|
|
3027
|
+
path: "/v1/prices/:id",
|
|
3028
|
+
pathParams: ID_PATH
|
|
3029
|
+
}),
|
|
3030
|
+
listPrices: declareRouteInputs({
|
|
3031
|
+
method: "GET",
|
|
3032
|
+
path: "/v1/prices",
|
|
3033
|
+
query: { ...LIST_QUERY, product: z.string().optional(), active: booleanInput.optional() }
|
|
3034
|
+
}),
|
|
3035
|
+
// ---------- Subscriptions ----------
|
|
3036
|
+
createSubscription: declareRouteInputs({
|
|
3037
|
+
method: "POST",
|
|
3038
|
+
path: "/v1/subscriptions",
|
|
3039
|
+
bodyEncoding: "form",
|
|
3040
|
+
body: CREATE_SUBSCRIPTION_BODY
|
|
3041
|
+
}),
|
|
3042
|
+
retrieveSubscription: declareRouteInputs({
|
|
3043
|
+
method: "GET",
|
|
3044
|
+
path: "/v1/subscriptions/:id",
|
|
3045
|
+
pathParams: ID_PATH
|
|
3046
|
+
}),
|
|
3047
|
+
updateSubscription: declareRouteInputs({
|
|
3048
|
+
method: "POST",
|
|
3049
|
+
path: "/v1/subscriptions/:id",
|
|
3050
|
+
pathParams: ID_PATH,
|
|
3051
|
+
bodyEncoding: "form",
|
|
3052
|
+
body: UPDATE_SUBSCRIPTION_BODY
|
|
3053
|
+
}),
|
|
3054
|
+
cancelSubscription: declareRouteInputs({
|
|
3055
|
+
method: "DELETE",
|
|
3056
|
+
path: "/v1/subscriptions/:id",
|
|
3057
|
+
pathParams: ID_PATH
|
|
3058
|
+
}),
|
|
3059
|
+
listSubscriptions: declareRouteInputs({
|
|
3060
|
+
method: "GET",
|
|
3061
|
+
path: "/v1/subscriptions",
|
|
3062
|
+
query: { ...LIST_QUERY, customer: z.string().optional(), status: z.string().optional() }
|
|
3063
|
+
}),
|
|
3064
|
+
// ---------- Invoices (reads only) ----------
|
|
3065
|
+
retrieveInvoice: declareRouteInputs({
|
|
3066
|
+
method: "GET",
|
|
3067
|
+
path: "/v1/invoices/:id",
|
|
3068
|
+
pathParams: ID_PATH
|
|
3069
|
+
}),
|
|
3070
|
+
listInvoices: declareRouteInputs({
|
|
3071
|
+
method: "GET",
|
|
3072
|
+
path: "/v1/invoices",
|
|
3073
|
+
query: LIST_QUERY
|
|
3074
|
+
}),
|
|
3075
|
+
// ---------- Balance ----------
|
|
3076
|
+
retrieveBalance: declareRouteInputs({
|
|
3077
|
+
method: "GET",
|
|
3078
|
+
path: "/v1/balance"
|
|
3079
|
+
}),
|
|
3080
|
+
listBalanceTransactions: declareRouteInputs({
|
|
3081
|
+
method: "GET",
|
|
3082
|
+
path: "/v1/balance_transactions",
|
|
3083
|
+
query: { ...LIST_QUERY, type: z.string().optional() }
|
|
3084
|
+
}),
|
|
3085
|
+
// ---------- Events ----------
|
|
3086
|
+
retrieveEvent: declareRouteInputs({
|
|
3087
|
+
method: "GET",
|
|
3088
|
+
path: "/v1/events/:id",
|
|
3089
|
+
pathParams: ID_PATH
|
|
3090
|
+
}),
|
|
3091
|
+
listEvents: declareRouteInputs({
|
|
3092
|
+
method: "GET",
|
|
3093
|
+
path: "/v1/events",
|
|
3094
|
+
query: { ...LIST_QUERY, type: z.string().optional() }
|
|
3095
|
+
})
|
|
3096
|
+
};
|
|
3097
|
+
|
|
3098
|
+
// ../packages/twin-stripe/dist/src/routes/payment-intents.js
|
|
2877
3099
|
function registerPaymentIntentRoutes(router, domain, recorder, runId) {
|
|
2878
|
-
router
|
|
2879
|
-
const body =
|
|
2880
|
-
const input = createPISchema.parse(body);
|
|
2881
|
-
const { body: piBody, delta } = domain.createPaymentIntent(accountId(c), input);
|
|
3100
|
+
declaredRoute(router, STRIPE_ROUTES.createPaymentIntent, recorder, runId, ({ body }, c) => {
|
|
3101
|
+
const { body: piBody, delta } = domain.createPaymentIntent(accountId(c), body);
|
|
2882
3102
|
return created(piBody, delta);
|
|
2883
|
-
})
|
|
2884
|
-
router
|
|
2885
|
-
router.
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
const { body, delta } = domain.
|
|
2892
|
-
return ok(
|
|
2893
|
-
})
|
|
2894
|
-
router
|
|
2895
|
-
const
|
|
2896
|
-
const { body, delta } = domain.updatePaymentIntent(accountId(c), c.req.param("id"), input);
|
|
2897
|
-
return ok(body, true, delta);
|
|
2898
|
-
}));
|
|
2899
|
-
router.post("/v1/payment_intents/:id/cancel", (c) => handle(c, recorder, runId, () => {
|
|
2900
|
-
const { body, delta } = domain.cancelPaymentIntent(accountId(c), c.req.param("id"));
|
|
3103
|
+
});
|
|
3104
|
+
declaredRoute(router, STRIPE_ROUTES.retrievePaymentIntent, recorder, runId, ({ path }, c) => ok(domain.retrievePaymentIntent(accountId(c), path.id)));
|
|
3105
|
+
declaredRoute(router, STRIPE_ROUTES.listPaymentIntents, recorder, runId, ({ query }, c) => ok(domain.listPaymentIntents(accountId(c), listQuery(query))));
|
|
3106
|
+
declaredRoute(router, STRIPE_ROUTES.confirmPaymentIntent, recorder, runId, ({ path, body }, c) => {
|
|
3107
|
+
const { body: piBody, delta } = domain.confirmPaymentIntent(accountId(c), path.id, body);
|
|
3108
|
+
return ok(piBody, true, delta);
|
|
3109
|
+
});
|
|
3110
|
+
declaredRoute(router, STRIPE_ROUTES.updatePaymentIntent, recorder, runId, ({ path, body }, c) => {
|
|
3111
|
+
const { body: piBody, delta } = domain.updatePaymentIntent(accountId(c), path.id, body);
|
|
3112
|
+
return ok(piBody, true, delta);
|
|
3113
|
+
});
|
|
3114
|
+
declaredRoute(router, STRIPE_ROUTES.cancelPaymentIntent, recorder, runId, ({ path }, c) => {
|
|
3115
|
+
const { body, delta } = domain.cancelPaymentIntent(accountId(c), path.id);
|
|
2901
3116
|
return ok(body, true, delta);
|
|
2902
|
-
})
|
|
2903
|
-
router
|
|
2904
|
-
const { body, delta } = domain.simulateCryptoDeposit(accountId(c),
|
|
3117
|
+
});
|
|
3118
|
+
declaredRoute(router, STRIPE_ROUTES.simulateCryptoDeposit, recorder, runId, ({ path }, c) => {
|
|
3119
|
+
const { body, delta } = domain.simulateCryptoDeposit(accountId(c), path.id);
|
|
2905
3120
|
return ok(body, true, delta);
|
|
2906
|
-
})
|
|
3121
|
+
});
|
|
2907
3122
|
}
|
|
2908
3123
|
|
|
2909
3124
|
// ../packages/twin-stripe/dist/src/routes/charges.js
|
|
2910
3125
|
function registerChargesRoutes(router, domain, recorder, runId) {
|
|
2911
|
-
router
|
|
2912
|
-
router
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
customer: c.req.query("customer")
|
|
2918
|
-
}));
|
|
2919
|
-
}));
|
|
3126
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveCharge, recorder, runId, ({ path }, c) => ok(domain.retrieveCharge(accountId(c), path.id)));
|
|
3127
|
+
declaredRoute(router, STRIPE_ROUTES.listCharges, recorder, runId, ({ query }, c) => ok(domain.listCharges(accountId(c), {
|
|
3128
|
+
...listQuery(query),
|
|
3129
|
+
payment_intent: query.payment_intent,
|
|
3130
|
+
customer: query.customer
|
|
3131
|
+
})));
|
|
2920
3132
|
}
|
|
2921
3133
|
|
|
2922
3134
|
// ../packages/twin-stripe/dist/src/routes/balance.js
|
|
2923
3135
|
function registerBalanceRoutes(router, domain, recorder, runId) {
|
|
2924
|
-
router
|
|
2925
|
-
router.
|
|
2926
|
-
const list = parseListQuery(c);
|
|
2927
|
-
return ok(domain.listBalanceTransactions(accountId(c), {
|
|
2928
|
-
...list,
|
|
2929
|
-
type: c.req.query("type")
|
|
2930
|
-
}));
|
|
2931
|
-
}));
|
|
3136
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveBalance, recorder, runId, (_input, c) => ok(domain.retrieveBalance(accountId(c))));
|
|
3137
|
+
declaredRoute(router, STRIPE_ROUTES.listBalanceTransactions, recorder, runId, ({ query }, c) => ok(domain.listBalanceTransactions(accountId(c), { ...listQuery(query), type: query.type })));
|
|
2932
3138
|
}
|
|
2933
3139
|
|
|
2934
3140
|
// ../packages/twin-stripe/dist/src/routes/events.js
|
|
2935
3141
|
function registerEventsRoutes(router, domain, recorder, runId) {
|
|
2936
|
-
router
|
|
2937
|
-
router.
|
|
2938
|
-
const list = parseListQuery(c);
|
|
2939
|
-
return ok(domain.listEvents(accountId(c), {
|
|
2940
|
-
...list,
|
|
2941
|
-
type: c.req.query("type")
|
|
2942
|
-
}));
|
|
2943
|
-
}));
|
|
3142
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveEvent, recorder, runId, ({ path }, c) => ok(domain.retrieveEvent(accountId(c), path.id)));
|
|
3143
|
+
declaredRoute(router, STRIPE_ROUTES.listEvents, recorder, runId, ({ query }, c) => ok(domain.listEvents(accountId(c), { ...listQuery(query), type: query.type })));
|
|
2944
3144
|
}
|
|
2945
3145
|
|
|
2946
3146
|
// ../packages/twin-stripe/dist/src/routes/refunds.js
|
|
2947
3147
|
function registerRefundsRoutes(router, domain, recorder, runId) {
|
|
2948
|
-
router.
|
|
2949
|
-
const body = await readJson(c);
|
|
3148
|
+
declaredRoute(router, STRIPE_ROUTES.createRefund, recorder, runId, ({ body, header }, c) => {
|
|
2950
3149
|
const { body: response, delta } = domain.createRefund(accountId(c), {
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
3150
|
+
// An absent `charge` still reaches the domain, which answers it with
|
|
3151
|
+
// Stripe's `parameter_missing`.
|
|
3152
|
+
charge: body.charge ?? "",
|
|
3153
|
+
amount: body.amount,
|
|
3154
|
+
reason: body.reason ?? null,
|
|
3155
|
+
idempotency_key: header["Idempotency-Key"] ?? null
|
|
2955
3156
|
});
|
|
2956
3157
|
return created(response, delta);
|
|
2957
|
-
})
|
|
2958
|
-
router
|
|
2959
|
-
router
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
payment_intent: c.req.query("payment_intent")
|
|
2965
|
-
}));
|
|
2966
|
-
}));
|
|
2967
|
-
}
|
|
2968
|
-
async function readJson(c) {
|
|
2969
|
-
const contentType = c.req.header("content-type") ?? "";
|
|
2970
|
-
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
2971
|
-
try {
|
|
2972
|
-
const parsed = await c.req.parseBody();
|
|
2973
|
-
return coerceFormBody(parsed);
|
|
2974
|
-
} catch {
|
|
2975
|
-
return {};
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2978
|
-
try {
|
|
2979
|
-
const body = await c.req.json();
|
|
2980
|
-
return body && typeof body === "object" ? body : {};
|
|
2981
|
-
} catch {
|
|
2982
|
-
return {};
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
function coerceFormBody(form) {
|
|
2986
|
-
const out = {};
|
|
2987
|
-
for (const [k, v] of Object.entries(form)) {
|
|
2988
|
-
if (typeof v === "string" && /^-?\d+$/.test(v) && k === "amount") {
|
|
2989
|
-
out[k] = Number(v);
|
|
2990
|
-
} else {
|
|
2991
|
-
out[k] = v;
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
return out;
|
|
3158
|
+
});
|
|
3159
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveRefund, recorder, runId, ({ path }, c) => ok(domain.retrieveRefund(accountId(c), path.id)));
|
|
3160
|
+
declaredRoute(router, STRIPE_ROUTES.listRefunds, recorder, runId, ({ query }, c) => ok(domain.listRefunds(accountId(c), {
|
|
3161
|
+
...listQuery(query),
|
|
3162
|
+
charge: query.charge,
|
|
3163
|
+
payment_intent: query.payment_intent
|
|
3164
|
+
})));
|
|
2995
3165
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
email: z.string().nullish(),
|
|
2999
|
-
description: z.string().nullish(),
|
|
3000
|
-
phone: z.string().nullish(),
|
|
3001
|
-
metadata: z.record(z.string(), z.string().nullable()).optional()
|
|
3002
|
-
});
|
|
3166
|
+
|
|
3167
|
+
// ../packages/twin-stripe/dist/src/routes/customers.js
|
|
3003
3168
|
function registerCustomersRoutes(router, domain, recorder, runId) {
|
|
3004
|
-
router
|
|
3005
|
-
const
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
}))
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
}));
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
router
|
|
3018
|
-
const
|
|
3019
|
-
const { body, delta } = domain.updateCustomer(accountId(c), c.req.param("id"), input);
|
|
3020
|
-
return ok(body, true, delta);
|
|
3021
|
-
}));
|
|
3022
|
-
router.delete("/v1/customers/:id", (c) => handle(c, recorder, runId, () => {
|
|
3023
|
-
const { body, delta } = domain.deleteCustomer(accountId(c), c.req.param("id"));
|
|
3169
|
+
declaredRoute(router, STRIPE_ROUTES.createCustomer, recorder, runId, ({ body }, c) => {
|
|
3170
|
+
const { body: response, delta } = domain.createCustomer(accountId(c), body);
|
|
3171
|
+
return created(response, delta);
|
|
3172
|
+
});
|
|
3173
|
+
declaredRoute(router, STRIPE_ROUTES.listCustomerPaymentMethods, recorder, runId, ({ path, query }, c) => ok(domain.listCustomerPaymentMethods(accountId(c), path.id, {
|
|
3174
|
+
...listQuery(query),
|
|
3175
|
+
type: query.type
|
|
3176
|
+
})));
|
|
3177
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveCustomer, recorder, runId, ({ path }, c) => ok(domain.retrieveCustomer(accountId(c), path.id)));
|
|
3178
|
+
declaredRoute(router, STRIPE_ROUTES.updateCustomer, recorder, runId, ({ path, body }, c) => {
|
|
3179
|
+
const { body: response, delta } = domain.updateCustomer(accountId(c), path.id, body);
|
|
3180
|
+
return ok(response, true, delta);
|
|
3181
|
+
});
|
|
3182
|
+
declaredRoute(router, STRIPE_ROUTES.deleteCustomer, recorder, runId, ({ path }, c) => {
|
|
3183
|
+
const { body, delta } = domain.deleteCustomer(accountId(c), path.id);
|
|
3024
3184
|
return ok(body, true, delta);
|
|
3025
|
-
})
|
|
3026
|
-
router.
|
|
3027
|
-
const list = parseListQuery(c);
|
|
3028
|
-
return ok(domain.listCustomers(accountId(c), { ...list, email: c.req.query("email") }));
|
|
3029
|
-
}));
|
|
3185
|
+
});
|
|
3186
|
+
declaredRoute(router, STRIPE_ROUTES.listCustomers, recorder, runId, ({ query }, c) => ok(domain.listCustomers(accountId(c), { ...listQuery(query), email: query.email })));
|
|
3030
3187
|
}
|
|
3031
3188
|
|
|
3032
3189
|
// ../packages/twin-stripe/dist/src/routes/payment-methods.js
|
|
3033
3190
|
function registerPaymentMethodsRoutes(router, domain, recorder, runId) {
|
|
3034
|
-
router
|
|
3035
|
-
const body = await readBodyForm(c);
|
|
3191
|
+
declaredRoute(router, STRIPE_ROUTES.createPaymentMethod, recorder, runId, ({ body }, c) => {
|
|
3036
3192
|
const { body: response, delta } = domain.createPaymentMethod(accountId(c), body);
|
|
3037
3193
|
return created(response, delta);
|
|
3038
|
-
})
|
|
3039
|
-
router
|
|
3040
|
-
router.
|
|
3041
|
-
|
|
3042
|
-
const customer = typeof body.customer === "string" ? body.customer : "";
|
|
3043
|
-
if (!customer) {
|
|
3194
|
+
});
|
|
3195
|
+
declaredRoute(router, STRIPE_ROUTES.retrievePaymentMethod, recorder, runId, ({ path }, c) => ok(domain.retrievePaymentMethod(accountId(c), path.id)));
|
|
3196
|
+
declaredRoute(router, STRIPE_ROUTES.attachPaymentMethod, recorder, runId, ({ path, body }, c) => {
|
|
3197
|
+
if (!body.customer) {
|
|
3044
3198
|
throw new TwinError("invalid_request_error", "parameter_missing", "Missing required param: customer.", { param: "customer", statusCode: 400 });
|
|
3045
3199
|
}
|
|
3046
|
-
const { body: response, delta } = domain.attachPaymentMethod(accountId(c),
|
|
3200
|
+
const { body: response, delta } = domain.attachPaymentMethod(accountId(c), path.id, body.customer);
|
|
3047
3201
|
return ok(response, true, delta);
|
|
3048
|
-
})
|
|
3049
|
-
router
|
|
3050
|
-
const { body, delta } = domain.detachPaymentMethod(accountId(c),
|
|
3202
|
+
});
|
|
3203
|
+
declaredRoute(router, STRIPE_ROUTES.detachPaymentMethod, recorder, runId, ({ path }, c) => {
|
|
3204
|
+
const { body, delta } = domain.detachPaymentMethod(accountId(c), path.id);
|
|
3051
3205
|
return ok(body, true, delta);
|
|
3052
|
-
})
|
|
3206
|
+
});
|
|
3053
3207
|
}
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
var productFieldsSchema = z.object({
|
|
3057
|
-
name: z.string().min(1).optional(),
|
|
3058
|
-
description: z.string().nullish(),
|
|
3059
|
-
active: formBool2,
|
|
3060
|
-
metadata: metadataSchema
|
|
3061
|
-
});
|
|
3062
|
-
var createPriceSchema = z.object({
|
|
3063
|
-
currency: z.string().min(1).optional(),
|
|
3064
|
-
product: z.string().min(1).optional(),
|
|
3065
|
-
unit_amount: z.coerce.number().int().nonnegative().optional(),
|
|
3066
|
-
recurring: z.object({
|
|
3067
|
-
interval: z.string().min(1),
|
|
3068
|
-
interval_count: z.coerce.number().int().positive().optional()
|
|
3069
|
-
}).optional(),
|
|
3070
|
-
nickname: z.string().nullish(),
|
|
3071
|
-
lookup_key: z.string().nullish(),
|
|
3072
|
-
active: formBool2,
|
|
3073
|
-
metadata: metadataSchema
|
|
3074
|
-
});
|
|
3075
|
-
var createSubscriptionSchema = z.object({
|
|
3076
|
-
customer: z.string().min(1).optional(),
|
|
3077
|
-
items: z.array(z.object({
|
|
3078
|
-
price: z.string().min(1).optional(),
|
|
3079
|
-
quantity: z.coerce.number().int().positive().optional()
|
|
3080
|
-
})).optional(),
|
|
3081
|
-
cancel_at_period_end: formBool2,
|
|
3082
|
-
metadata: metadataSchema
|
|
3083
|
-
});
|
|
3084
|
-
var updateSubscriptionSchema = z.object({
|
|
3085
|
-
cancel_at_period_end: formBool2,
|
|
3086
|
-
metadata: metadataSchema
|
|
3087
|
-
});
|
|
3208
|
+
|
|
3209
|
+
// ../packages/twin-stripe/dist/src/routes/billing.js
|
|
3088
3210
|
function registerBillingRoutes(router, domain, recorder, runId) {
|
|
3089
|
-
router
|
|
3090
|
-
const
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
}));
|
|
3094
|
-
router
|
|
3095
|
-
router
|
|
3096
|
-
const
|
|
3097
|
-
return
|
|
3098
|
-
})
|
|
3099
|
-
router
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
router
|
|
3106
|
-
const
|
|
3107
|
-
return
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
}));
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
const { body, delta } = domain.
|
|
3116
|
-
return created(body, delta);
|
|
3117
|
-
}));
|
|
3118
|
-
router.get("/v1/subscriptions/:id", (c) => handle(c, recorder, runId, () => ok(domain.retrieveSubscription(accountId(c), c.req.param("id")))));
|
|
3119
|
-
router.post("/v1/subscriptions/:id", (c) => handle(c, recorder, runId, async () => {
|
|
3120
|
-
const input = updateSubscriptionSchema.parse(await readBodyForm(c));
|
|
3121
|
-
const { body, delta } = domain.updateSubscription(accountId(c), c.req.param("id"), input);
|
|
3122
|
-
return ok(body, true, delta);
|
|
3123
|
-
}));
|
|
3124
|
-
router.delete("/v1/subscriptions/:id", (c) => handle(c, recorder, runId, () => {
|
|
3125
|
-
const { body, delta } = domain.cancelSubscription(accountId(c), c.req.param("id"));
|
|
3211
|
+
declaredRoute(router, STRIPE_ROUTES.createProduct, recorder, runId, ({ body }, c) => {
|
|
3212
|
+
const { body: response, delta } = domain.createProduct(accountId(c), body);
|
|
3213
|
+
return created(response, delta);
|
|
3214
|
+
});
|
|
3215
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveProduct, recorder, runId, ({ path }, c) => ok(domain.retrieveProduct(accountId(c), path.id)));
|
|
3216
|
+
declaredRoute(router, STRIPE_ROUTES.listProducts, recorder, runId, ({ query }, c) => ok(domain.listProducts(accountId(c), { ...listQuery(query), active: query.active })));
|
|
3217
|
+
declaredRoute(router, STRIPE_ROUTES.createPrice, recorder, runId, ({ body }, c) => {
|
|
3218
|
+
const { body: response, delta } = domain.createPrice(accountId(c), body);
|
|
3219
|
+
return created(response, delta);
|
|
3220
|
+
});
|
|
3221
|
+
declaredRoute(router, STRIPE_ROUTES.retrievePrice, recorder, runId, ({ path }, c) => ok(domain.retrievePrice(accountId(c), path.id)));
|
|
3222
|
+
declaredRoute(router, STRIPE_ROUTES.listPrices, recorder, runId, ({ query }, c) => ok(domain.listPrices(accountId(c), {
|
|
3223
|
+
...listQuery(query),
|
|
3224
|
+
product: query.product,
|
|
3225
|
+
active: query.active
|
|
3226
|
+
})));
|
|
3227
|
+
declaredRoute(router, STRIPE_ROUTES.createSubscription, recorder, runId, ({ body }, c) => {
|
|
3228
|
+
const { body: response, delta } = domain.createSubscription(accountId(c), body);
|
|
3229
|
+
return created(response, delta);
|
|
3230
|
+
});
|
|
3231
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveSubscription, recorder, runId, ({ path }, c) => ok(domain.retrieveSubscription(accountId(c), path.id)));
|
|
3232
|
+
declaredRoute(router, STRIPE_ROUTES.updateSubscription, recorder, runId, ({ path, body }, c) => {
|
|
3233
|
+
const { body: response, delta } = domain.updateSubscription(accountId(c), path.id, body);
|
|
3234
|
+
return ok(response, true, delta);
|
|
3235
|
+
});
|
|
3236
|
+
declaredRoute(router, STRIPE_ROUTES.cancelSubscription, recorder, runId, ({ path }, c) => {
|
|
3237
|
+
const { body, delta } = domain.cancelSubscription(accountId(c), path.id);
|
|
3126
3238
|
return ok(body, true, delta);
|
|
3127
|
-
})
|
|
3128
|
-
router
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
}));
|
|
3136
|
-
router.get("/v1/invoices/:id", (c) => handle(c, recorder, runId, () => ok(domain.retrieveInvoice(accountId(c), c.req.param("id")))));
|
|
3137
|
-
router.get("/v1/invoices", (c) => handle(c, recorder, runId, () => ok(domain.listInvoices(accountId(c), parseListQuery(c)))));
|
|
3138
|
-
}
|
|
3139
|
-
function queryBool(value) {
|
|
3140
|
-
if (value === "true")
|
|
3141
|
-
return true;
|
|
3142
|
-
if (value === "false")
|
|
3143
|
-
return false;
|
|
3144
|
-
return void 0;
|
|
3239
|
+
});
|
|
3240
|
+
declaredRoute(router, STRIPE_ROUTES.listSubscriptions, recorder, runId, ({ query }, c) => ok(domain.listSubscriptions(accountId(c), {
|
|
3241
|
+
...listQuery(query),
|
|
3242
|
+
customer: query.customer,
|
|
3243
|
+
status: query.status
|
|
3244
|
+
})));
|
|
3245
|
+
declaredRoute(router, STRIPE_ROUTES.retrieveInvoice, recorder, runId, ({ path }, c) => ok(domain.retrieveInvoice(accountId(c), path.id)));
|
|
3246
|
+
declaredRoute(router, STRIPE_ROUTES.listInvoices, recorder, runId, ({ query }, c) => ok(domain.listInvoices(accountId(c), listQuery(query))));
|
|
3145
3247
|
}
|
|
3146
3248
|
|
|
3147
3249
|
// ../packages/twin-stripe/dist/src/routes/index.js
|
|
@@ -3910,7 +4012,7 @@ var createdRange = {
|
|
|
3910
4012
|
})
|
|
3911
4013
|
]).optional()
|
|
3912
4014
|
};
|
|
3913
|
-
function
|
|
4015
|
+
function flattenCreated2(input) {
|
|
3914
4016
|
if (input.created === void 0)
|
|
3915
4017
|
return {};
|
|
3916
4018
|
if (typeof input.created === "number") {
|
|
@@ -4128,7 +4230,7 @@ function executeTool(domain, accountId2, name, input) {
|
|
|
4128
4230
|
case "retrieve_payment_intent":
|
|
4129
4231
|
return domain.retrievePaymentIntent(accountId2, parsed.id);
|
|
4130
4232
|
case "list_payment_intents": {
|
|
4131
|
-
const flat =
|
|
4233
|
+
const flat = flattenCreated2(parsed);
|
|
4132
4234
|
return domain.listPaymentIntents(accountId2, { ...parsed, ...flat });
|
|
4133
4235
|
}
|
|
4134
4236
|
case "confirm_payment_intent":
|
|
@@ -4146,7 +4248,7 @@ function executeTool(domain, accountId2, name, input) {
|
|
|
4146
4248
|
case "retrieve_charge":
|
|
4147
4249
|
return domain.retrieveCharge(accountId2, parsed.id);
|
|
4148
4250
|
case "list_charges": {
|
|
4149
|
-
const flat =
|
|
4251
|
+
const flat = flattenCreated2(parsed);
|
|
4150
4252
|
return domain.listCharges(accountId2, { ...parsed, ...flat });
|
|
4151
4253
|
}
|
|
4152
4254
|
case "create_refund":
|
|
@@ -4154,7 +4256,7 @@ function executeTool(domain, accountId2, name, input) {
|
|
|
4154
4256
|
case "retrieve_refund":
|
|
4155
4257
|
return domain.retrieveRefund(accountId2, parsed.id);
|
|
4156
4258
|
case "list_refunds": {
|
|
4157
|
-
const flat =
|
|
4259
|
+
const flat = flattenCreated2(parsed);
|
|
4158
4260
|
return domain.listRefunds(accountId2, { ...parsed, ...flat });
|
|
4159
4261
|
}
|
|
4160
4262
|
case "create_customer":
|
|
@@ -4168,7 +4270,7 @@ function executeTool(domain, accountId2, name, input) {
|
|
|
4168
4270
|
case "delete_customer":
|
|
4169
4271
|
return domain.deleteCustomer(accountId2, parsed.id).body;
|
|
4170
4272
|
case "list_customers": {
|
|
4171
|
-
const flat =
|
|
4273
|
+
const flat = flattenCreated2(parsed);
|
|
4172
4274
|
return domain.listCustomers(accountId2, { ...parsed, ...flat });
|
|
4173
4275
|
}
|
|
4174
4276
|
case "list_customer_payment_methods": {
|
|
@@ -4186,13 +4288,13 @@ function executeTool(domain, accountId2, name, input) {
|
|
|
4186
4288
|
case "retrieve_balance":
|
|
4187
4289
|
return domain.retrieveBalance(accountId2);
|
|
4188
4290
|
case "list_balance_transactions": {
|
|
4189
|
-
const flat =
|
|
4291
|
+
const flat = flattenCreated2(parsed);
|
|
4190
4292
|
return domain.listBalanceTransactions(accountId2, { ...parsed, ...flat });
|
|
4191
4293
|
}
|
|
4192
4294
|
case "retrieve_event":
|
|
4193
4295
|
return domain.retrieveEvent(accountId2, parsed.id);
|
|
4194
4296
|
case "list_events": {
|
|
4195
|
-
const flat =
|
|
4297
|
+
const flat = flattenCreated2(parsed);
|
|
4196
4298
|
return domain.listEvents(accountId2, { ...parsed, ...flat });
|
|
4197
4299
|
}
|
|
4198
4300
|
}
|