mtmsdk 0.0.42 → 0.0.44
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/cloud-account/platform-configs.d.ts +64 -0
- package/dist/cloud-account/platform-configs.d.ts.map +1 -0
- package/dist/cloud-account/platform-configs.js +44 -0
- package/dist/cloud-account/platform-configs.js.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/@tanstack/react-query.gen.d.ts +202 -8
- package/dist/gomtmapi/@tanstack/react-query.gen.d.ts.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/@tanstack/react-query.gen.js +300 -10
- package/dist/gomtmapi/@tanstack/react-query.gen.js.map +1 -0
- package/dist/{opencode → gomtmapi}/client/client.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/client/client.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/client/index.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/client/index.js.map +1 -1
- package/dist/{opencode → gomtmapi}/client/types.gen.d.ts.map +1 -1
- package/dist/gomtmapi/client/types.gen.js.map +1 -0
- package/dist/{opencode → gomtmapi}/client/utils.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/client/utils.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/client.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/client.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/auth.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/auth.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/bodySerializer.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/bodySerializer.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/params.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/params.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/pathSerializer.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/pathSerializer.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/queryKeySerializer.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/queryKeySerializer.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/serverSentEvents.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/serverSentEvents.gen.js.map +1 -1
- package/dist/{opencode → gomtmapi}/core/types.gen.d.ts.map +1 -1
- package/dist/gomtmapi/core/types.gen.js.map +1 -0
- package/dist/{opencode → gomtmapi}/core/utils.gen.d.ts.map +1 -1
- package/dist/{opencode → gomtmapi}/core/utils.gen.js.map +1 -1
- package/dist/gomtmapi/index.d.ts +3 -0
- package/dist/gomtmapi/index.d.ts.map +1 -0
- package/dist/gomtmapi/index.js +3 -0
- package/dist/gomtmapi/index.js.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/schemas.gen.d.ts +337 -50
- package/dist/gomtmapi/schemas.gen.d.ts.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/schemas.gen.js +355 -50
- package/dist/gomtmapi/schemas.gen.js.map +1 -0
- package/dist/gomtmapi/sdk.gen.d.ts +378 -0
- package/dist/gomtmapi/sdk.gen.d.ts.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/sdk.gen.js +234 -15
- package/dist/gomtmapi/sdk.gen.js.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/types.gen.d.ts +494 -50
- package/dist/gomtmapi/types.gen.d.ts.map +1 -0
- package/dist/gomtmapi/types.gen.js.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/zod.gen.d.ts +391 -45
- package/dist/gomtmapi/zod.gen.d.ts.map +1 -0
- package/dist/{gomtmapi_v2 → gomtmapi}/zod.gen.js +270 -31
- package/dist/gomtmapi/zod.gen.js.map +1 -0
- package/dist/lib/logger/index.d.ts +3 -0
- package/dist/lib/logger/index.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +14 -2
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +1 -1
- package/dist/lib/schema.js.map +1 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.d.ts +29 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.js +17 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.js.map +1 -1
- package/dist/mtgate_api/index.d.ts +2 -2
- package/dist/mtgate_api/index.d.ts.map +1 -1
- package/dist/mtgate_api/index.js +1 -1
- package/dist/mtgate_api/index.js.map +1 -1
- package/dist/mtgate_api/schemas.gen.d.ts +1 -0
- package/dist/mtgate_api/schemas.gen.d.ts.map +1 -1
- package/dist/mtgate_api/schemas.gen.js +8 -1
- package/dist/mtgate_api/schemas.gen.js.map +1 -1
- package/dist/mtgate_api/sdk.gen.d.ts +5 -1
- package/dist/mtgate_api/sdk.gen.d.ts.map +1 -1
- package/dist/mtgate_api/sdk.gen.js +4 -0
- package/dist/mtgate_api/sdk.gen.js.map +1 -1
- package/dist/mtgate_api/types.gen.d.ts +7 -1
- package/dist/mtgate_api/types.gen.d.ts.map +1 -1
- package/dist/mtgate_api/zod.gen.d.ts +26 -3
- package/dist/mtgate_api/zod.gen.d.ts.map +1 -1
- package/dist/mtgate_api/zod.gen.js +12 -1
- package/dist/mtgate_api/zod.gen.js.map +1 -1
- package/dist/openclaw/client-info.d.ts +56 -0
- package/dist/openclaw/client-info.d.ts.map +1 -0
- package/dist/openclaw/client-info.js +44 -0
- package/dist/openclaw/client-info.js.map +1 -0
- package/dist/openclaw/device-auth-utils.d.ts +13 -0
- package/dist/openclaw/device-auth-utils.d.ts.map +1 -0
- package/dist/openclaw/device-auth-utils.js +20 -0
- package/dist/openclaw/device-auth-utils.js.map +1 -0
- package/dist/openclaw/device-auth.d.ts +21 -0
- package/dist/openclaw/device-auth.d.ts.map +1 -0
- package/dist/openclaw/device-auth.js +84 -0
- package/dist/openclaw/device-auth.js.map +1 -0
- package/dist/openclaw/device-identity.d.ts +8 -0
- package/dist/openclaw/device-identity.d.ts.map +1 -0
- package/dist/openclaw/device-identity.js +87 -0
- package/dist/openclaw/device-identity.js.map +1 -0
- package/dist/openclaw/gateway.d.ts +86 -0
- package/dist/openclaw/gateway.d.ts.map +1 -0
- package/dist/openclaw/gateway.js +268 -0
- package/dist/openclaw/gateway.js.map +1 -0
- package/dist/openclaw/types.d.ts +473 -0
- package/dist/openclaw/types.d.ts.map +1 -0
- package/dist/openclaw/types.js +2 -0
- package/dist/openclaw/types.js.map +1 -0
- package/dist/openclaw/uuid.d.ts +6 -0
- package/dist/openclaw/uuid.d.ts.map +1 -0
- package/dist/openclaw/uuid.js +39 -0
- package/dist/openclaw/uuid.js.map +1 -0
- package/dist/sbapi/@tanstack/react-query.gen.d.ts +3251 -6
- package/dist/sbapi/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/sbapi/@tanstack/react-query.gen.js +6050 -6
- package/dist/sbapi/@tanstack/react-query.gen.js.map +1 -1
- package/dist/sbapi/client.gen.d.ts.map +1 -1
- package/dist/sbapi/client.gen.js +1 -1
- package/dist/sbapi/client.gen.js.map +1 -1
- package/dist/sbapi/index.d.ts +2 -2
- package/dist/sbapi/index.d.ts.map +1 -1
- package/dist/sbapi/index.js +1 -1
- package/dist/sbapi/index.js.map +1 -1
- package/dist/sbapi/schemas.gen.d.ts +2320 -36
- package/dist/sbapi/schemas.gen.d.ts.map +1 -1
- package/dist/sbapi/schemas.gen.js +2593 -45
- package/dist/sbapi/schemas.gen.js.map +1 -1
- package/dist/sbapi/sdk.gen.d.ts +819 -2
- package/dist/sbapi/sdk.gen.d.ts.map +1 -1
- package/dist/sbapi/sdk.gen.js +2463 -1
- package/dist/sbapi/sdk.gen.js.map +1 -1
- package/dist/sbapi/types.gen.d.ts +11701 -29
- package/dist/sbapi/types.gen.d.ts.map +1 -1
- package/dist/sbapi/zod.gen.d.ts +8134 -26
- package/dist/sbapi/zod.gen.d.ts.map +1 -1
- package/dist/sbapi/zod.gen.js +6572 -18
- package/dist/sbapi/zod.gen.js.map +1 -1
- package/dist/sbmng/@tanstack/react-query.gen.d.ts +253 -157
- package/dist/sbmng/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/sbmng/@tanstack/react-query.gen.js +241 -145
- package/dist/sbmng/@tanstack/react-query.gen.js.map +1 -1
- package/dist/sbmng/index.d.ts +2 -2
- package/dist/sbmng/index.d.ts.map +1 -1
- package/dist/sbmng/index.js +1 -1
- package/dist/sbmng/index.js.map +1 -1
- package/dist/sbmng/schemas.gen.d.ts +1035 -917
- package/dist/sbmng/schemas.gen.d.ts.map +1 -1
- package/dist/sbmng/schemas.gen.js +1219 -1067
- package/dist/sbmng/schemas.gen.js.map +1 -1
- package/dist/sbmng/sdk.gen.d.ts +62 -38
- package/dist/sbmng/sdk.gen.d.ts.map +1 -1
- package/dist/sbmng/sdk.gen.js +140 -84
- package/dist/sbmng/sdk.gen.js.map +1 -1
- package/dist/sbmng/types.gen.d.ts +1214 -991
- package/dist/sbmng/types.gen.d.ts.map +1 -1
- package/dist/supabase/auth-provider.d.ts +4 -0
- package/dist/supabase/auth-provider.d.ts.map +1 -0
- package/dist/supabase/auth-provider.js +45 -0
- package/dist/supabase/auth-provider.js.map +1 -0
- package/dist/supabase/cursor-pagination.d.ts +92 -0
- package/dist/supabase/cursor-pagination.d.ts.map +1 -0
- package/dist/supabase/cursor-pagination.js +116 -0
- package/dist/supabase/cursor-pagination.js.map +1 -0
- package/dist/supabase/schema/browser.d.ts.map +1 -0
- package/dist/supabase/schema/browser.js.map +1 -0
- package/dist/supabase/schema/index.d.ts +29 -0
- package/dist/supabase/schema/index.d.ts.map +1 -0
- package/dist/supabase/schema/index.js +38 -0
- package/dist/supabase/schema/index.js.map +1 -0
- package/dist/supabase/supabase-client.d.ts +1912 -1128
- package/dist/supabase/supabase-client.d.ts.map +1 -1
- package/dist/supabase/supabase.d.ts +4466 -2898
- package/dist/supabase/supabase.d.ts.map +1 -1
- package/dist/supabase/supabase.js +7 -4
- package/dist/supabase/supabase.js.map +1 -1
- package/dist/supabase/use-sb-query/use-query.d.ts +1 -1
- package/dist/supabase/use-sb-query/use-query.d.ts.map +1 -1
- package/dist/supabase/use-sb-query/use-query.js +2 -6
- package/dist/supabase/use-sb-query/use-query.js.map +1 -1
- package/dist/supabase/use-sb-query/use-rpc-mutation.d.ts +61 -0
- package/dist/supabase/use-sb-query/use-rpc-mutation.d.ts.map +1 -0
- package/dist/supabase/use-sb-query/use-rpc-mutation.js +63 -0
- package/dist/supabase/use-sb-query/use-rpc-mutation.js.map +1 -0
- package/dist/supabase/use-sb-query/use-rpc-query.d.ts +124 -0
- package/dist/supabase/use-sb-query/use-rpc-query.d.ts.map +1 -0
- package/dist/supabase/use-sb-query/use-rpc-query.js +91 -0
- package/dist/supabase/use-sb-query/use-rpc-query.js.map +1 -0
- package/dist/supabase/utils.d.ts +1 -1
- package/dist/supabase/utils.d.ts.map +1 -1
- package/dist/types/database.schemas.d.ts +3911 -0
- package/dist/types/database.schemas.d.ts.map +1 -0
- package/dist/types/database.schemas.js +3180 -0
- package/dist/types/database.schemas.js.map +1 -0
- package/dist/types/database.types.d.ts +1923 -1134
- package/dist/types/database.types.d.ts.map +1 -1
- package/dist/types/database.types.js +24 -0
- package/dist/types/database.types.js.map +1 -1
- package/dist/types/index.d.ts +47 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +27 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/rpc.schemas.d.ts +64 -0
- package/dist/types/rpc.schemas.d.ts.map +1 -0
- package/dist/types/rpc.schemas.js +122 -0
- package/dist/types/rpc.schemas.js.map +1 -0
- package/package.json +48 -39
- package/src/adk/api/client.ts +46 -0
- package/src/adk/core/constants/tool-icons.ts +51 -0
- package/src/adk/core/models/AgentBuilder.ts +80 -0
- package/src/adk/core/models/AgentRunRequest.ts +33 -0
- package/src/adk/core/models/Eval.ts +70 -0
- package/src/adk/core/models/LiveRequest.ts +23 -0
- package/src/adk/core/models/RuntimeConfig.ts +33 -0
- package/src/adk/core/models/Session.ts +52 -0
- package/src/adk/core/models/Trace.ts +42 -0
- package/src/adk/core/models/types.ts +255 -0
- package/src/api_hatchet/@tanstack/react-query.gen.ts +3025 -0
- package/src/api_hatchet/client/client.gen.ts +311 -0
- package/src/api_hatchet/client/index.ts +25 -0
- package/src/api_hatchet/client/types.gen.ts +241 -0
- package/src/api_hatchet/client/utils.gen.ts +332 -0
- package/{dist/opencode/client.gen.d.ts → src/api_hatchet/client.gen.ts} +6 -3
- package/src/api_hatchet/core/auth.gen.ts +42 -0
- package/src/api_hatchet/core/bodySerializer.gen.ts +100 -0
- package/src/api_hatchet/core/params.gen.ts +176 -0
- package/src/api_hatchet/core/pathSerializer.gen.ts +181 -0
- package/src/api_hatchet/core/queryKeySerializer.gen.ts +136 -0
- package/src/api_hatchet/core/serverSentEvents.gen.ts +266 -0
- package/src/api_hatchet/core/types.gen.ts +118 -0
- package/src/api_hatchet/core/utils.gen.ts +143 -0
- package/src/api_hatchet/index.ts +4 -0
- package/src/api_hatchet/schemas.gen.ts +4961 -0
- package/src/api_hatchet/sdk.gen.ts +1994 -0
- package/src/api_hatchet/types.gen.ts +7688 -0
- package/src/api_hatchet/zod.gen.ts +3230 -0
- package/src/cloud-account/platform-configs.ts +73 -0
- package/src/gomtmapi/@tanstack/react-query.gen.ts +757 -0
- package/src/gomtmapi/client/client.gen.ts +311 -0
- package/src/gomtmapi/client/index.ts +25 -0
- package/src/gomtmapi/client/types.gen.ts +241 -0
- package/src/gomtmapi/client/utils.gen.ts +332 -0
- package/src/gomtmapi/client.gen.ts +16 -0
- package/src/gomtmapi/core/auth.gen.ts +42 -0
- package/src/gomtmapi/core/bodySerializer.gen.ts +100 -0
- package/src/gomtmapi/core/params.gen.ts +176 -0
- package/src/gomtmapi/core/pathSerializer.gen.ts +181 -0
- package/src/gomtmapi/core/queryKeySerializer.gen.ts +136 -0
- package/src/gomtmapi/core/serverSentEvents.gen.ts +266 -0
- package/src/gomtmapi/core/types.gen.ts +118 -0
- package/src/gomtmapi/core/utils.gen.ts +143 -0
- package/src/gomtmapi/index.ts +4 -0
- package/src/gomtmapi/schemas.gen.ts +904 -0
- package/src/gomtmapi/sdk.gen.ts +541 -0
- package/src/gomtmapi/types.gen.ts +1456 -0
- package/src/gomtmapi/zod.gen.ts +758 -0
- package/src/index.ts +5 -0
- package/src/lib/aisdk/types.ts +8 -0
- package/src/lib/logger/index.ts +8 -0
- package/src/lib/schema.ts +50 -0
- package/src/lib/utils.ts +54 -0
- package/src/mtgate_api/@tanstack/react-query.gen.ts +175 -0
- package/src/mtgate_api/client/client.gen.ts +311 -0
- package/src/mtgate_api/client/index.ts +25 -0
- package/src/mtgate_api/client/types.gen.ts +241 -0
- package/src/mtgate_api/client/utils.gen.ts +332 -0
- package/src/mtgate_api/client.gen.ts +16 -0
- package/src/mtgate_api/core/auth.gen.ts +42 -0
- package/src/mtgate_api/core/bodySerializer.gen.ts +100 -0
- package/src/mtgate_api/core/params.gen.ts +176 -0
- package/src/mtgate_api/core/pathSerializer.gen.ts +181 -0
- package/src/mtgate_api/core/queryKeySerializer.gen.ts +136 -0
- package/src/mtgate_api/core/serverSentEvents.gen.ts +266 -0
- package/src/mtgate_api/core/types.gen.ts +118 -0
- package/src/mtgate_api/core/utils.gen.ts +143 -0
- package/src/mtgate_api/index.ts +4 -0
- package/src/mtgate_api/schemas.gen.ts +337 -0
- package/src/mtgate_api/sdk.gen.ts +61 -0
- package/src/mtgate_api/types.gen.ts +324 -0
- package/src/mtgate_api/zod.gen.ts +234 -0
- package/src/mtmai_api/@tanstack/react-query.gen.ts +1010 -0
- package/src/mtmai_api/client/client.gen.ts +311 -0
- package/src/mtmai_api/client/index.ts +25 -0
- package/src/mtmai_api/client/types.gen.ts +241 -0
- package/src/mtmai_api/client/utils.gen.ts +332 -0
- package/src/mtmai_api/client.gen.ts +16 -0
- package/src/mtmai_api/core/auth.gen.ts +42 -0
- package/src/mtmai_api/core/bodySerializer.gen.ts +100 -0
- package/src/mtmai_api/core/params.gen.ts +176 -0
- package/src/mtmai_api/core/pathSerializer.gen.ts +181 -0
- package/src/mtmai_api/core/queryKeySerializer.gen.ts +136 -0
- package/src/mtmai_api/core/serverSentEvents.gen.ts +266 -0
- package/src/mtmai_api/core/types.gen.ts +118 -0
- package/src/mtmai_api/core/utils.gen.ts +143 -0
- package/src/mtmai_api/index.ts +4 -0
- package/src/mtmai_api/schemas.gen.ts +9980 -0
- package/src/mtmai_api/sdk.gen.ts +471 -0
- package/src/mtmai_api/types.gen.ts +7609 -0
- package/src/mtmai_api/zod.gen.ts +5101 -0
- package/src/openclaw/client-info.ts +63 -0
- package/src/openclaw/device-auth-utils.ts +31 -0
- package/src/openclaw/device-auth.ts +96 -0
- package/src/openclaw/device-identity.ts +108 -0
- package/src/openclaw/gateway.ts +351 -0
- package/src/openclaw/types.ts +518 -0
- package/src/openclaw/uuid.ts +48 -0
- package/src/sbapi/@tanstack/react-query.gen.ts +6591 -0
- package/src/sbapi/client/client.gen.ts +311 -0
- package/src/sbapi/client/index.ts +25 -0
- package/src/sbapi/client/types.gen.ts +241 -0
- package/src/sbapi/client/utils.gen.ts +332 -0
- package/src/sbapi/client.gen.ts +16 -0
- package/src/sbapi/core/auth.gen.ts +42 -0
- package/src/sbapi/core/bodySerializer.gen.ts +100 -0
- package/src/sbapi/core/params.gen.ts +176 -0
- package/src/sbapi/core/pathSerializer.gen.ts +181 -0
- package/src/sbapi/core/queryKeySerializer.gen.ts +136 -0
- package/src/sbapi/core/serverSentEvents.gen.ts +266 -0
- package/src/sbapi/core/types.gen.ts +118 -0
- package/src/sbapi/core/utils.gen.ts +143 -0
- package/src/sbapi/index.ts +4 -0
- package/src/sbapi/schemas.gen.ts +2643 -0
- package/src/sbapi/sdk.gen.ts +2822 -0
- package/src/sbapi/types.gen.ts +12503 -0
- package/src/sbapi/zod.gen.ts +7021 -0
- package/src/sbmng/@tanstack/react-query.gen.ts +2999 -0
- package/src/sbmng/client/client.gen.ts +311 -0
- package/src/sbmng/client/index.ts +25 -0
- package/src/sbmng/client/types.gen.ts +241 -0
- package/src/sbmng/client/utils.gen.ts +332 -0
- package/src/sbmng/client.gen.ts +16 -0
- package/src/sbmng/core/auth.gen.ts +42 -0
- package/src/sbmng/core/bodySerializer.gen.ts +100 -0
- package/src/sbmng/core/params.gen.ts +176 -0
- package/src/sbmng/core/pathSerializer.gen.ts +181 -0
- package/src/sbmng/core/queryKeySerializer.gen.ts +136 -0
- package/src/sbmng/core/serverSentEvents.gen.ts +266 -0
- package/src/sbmng/core/types.gen.ts +118 -0
- package/src/sbmng/core/utils.gen.ts +143 -0
- package/src/sbmng/index.ts +4 -0
- package/src/sbmng/schemas.gen.ts +9680 -0
- package/src/sbmng/sdk.gen.ts +1771 -0
- package/src/sbmng/types.gen.ts +7956 -0
- package/src/supabase/auth-provider.tsx +67 -0
- package/src/supabase/context.tsx +51 -0
- package/src/supabase/cursor-pagination.ts +155 -0
- package/src/supabase/schema/browser.ts +45 -0
- package/src/supabase/schema/index.ts +50 -0
- package/src/supabase/supabase-client.ts +30 -0
- package/src/supabase/supabase.ts +65 -0
- package/src/supabase/use-sb-query/build-query-opts.ts +56 -0
- package/src/supabase/use-sb-query/key.ts +57 -0
- package/src/supabase/use-sb-query/prefetch.ts +59 -0
- package/src/supabase/use-sb-query/use-query.ts +340 -0
- package/src/supabase/use-sb-query/use-rpc-mutation.ts +83 -0
- package/src/supabase/use-sb-query/use-rpc-query.ts +230 -0
- package/src/supabase/utils.ts +75 -0
- package/src/types/database.schemas.ts +3804 -0
- package/src/types/database.types.ts +3828 -0
- package/src/types/index.ts +119 -0
- package/src/types/rpc.schemas.ts +157 -0
- package/dist/gomtmapi_v2/@tanstack/react-query.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/@tanstack/react-query.gen.js.map +0 -1
- package/dist/gomtmapi_v2/client/client.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/client/client.gen.js.map +0 -1
- package/dist/gomtmapi_v2/client/index.d.ts.map +0 -1
- package/dist/gomtmapi_v2/client/index.js.map +0 -1
- package/dist/gomtmapi_v2/client/types.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/client/types.gen.js.map +0 -1
- package/dist/gomtmapi_v2/client/utils.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/client/utils.gen.js.map +0 -1
- package/dist/gomtmapi_v2/client.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/client.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/auth.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/auth.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/bodySerializer.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/bodySerializer.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/params.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/params.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/pathSerializer.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/pathSerializer.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/queryKeySerializer.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/queryKeySerializer.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/serverSentEvents.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/serverSentEvents.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/types.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/types.gen.js.map +0 -1
- package/dist/gomtmapi_v2/core/utils.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/core/utils.gen.js.map +0 -1
- package/dist/gomtmapi_v2/index.d.ts +0 -3
- package/dist/gomtmapi_v2/index.d.ts.map +0 -1
- package/dist/gomtmapi_v2/index.js +0 -3
- package/dist/gomtmapi_v2/index.js.map +0 -1
- package/dist/gomtmapi_v2/schemas.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/schemas.gen.js.map +0 -1
- package/dist/gomtmapi_v2/sdk.gen.d.ts +0 -208
- package/dist/gomtmapi_v2/sdk.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/sdk.gen.js.map +0 -1
- package/dist/gomtmapi_v2/types.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/types.gen.js.map +0 -1
- package/dist/gomtmapi_v2/zod.gen.d.ts.map +0 -1
- package/dist/gomtmapi_v2/zod.gen.js.map +0 -1
- package/dist/opencode/@tanstack/react-query.gen.d.ts +0 -1903
- package/dist/opencode/@tanstack/react-query.gen.d.ts.map +0 -1
- package/dist/opencode/@tanstack/react-query.gen.js +0 -1696
- package/dist/opencode/@tanstack/react-query.gen.js.map +0 -1
- package/dist/opencode/client/client.gen.d.ts +0 -3
- package/dist/opencode/client/client.gen.js +0 -236
- package/dist/opencode/client/index.d.ts +0 -9
- package/dist/opencode/client/index.js +0 -7
- package/dist/opencode/client/types.gen.d.ts +0 -118
- package/dist/opencode/client/types.gen.js +0 -3
- package/dist/opencode/client/types.gen.js.map +0 -1
- package/dist/opencode/client/utils.gen.d.ts +0 -34
- package/dist/opencode/client/utils.gen.js +0 -232
- package/dist/opencode/client.gen.js +0 -4
- package/dist/opencode/core/auth.gen.d.ts +0 -19
- package/dist/opencode/core/auth.gen.js +0 -15
- package/dist/opencode/core/bodySerializer.gen.d.ts +0 -26
- package/dist/opencode/core/bodySerializer.gen.js +0 -58
- package/dist/opencode/core/params.gen.d.ts +0 -44
- package/dist/opencode/core/params.gen.js +0 -101
- package/dist/opencode/core/pathSerializer.gen.d.ts +0 -34
- package/dist/opencode/core/pathSerializer.gen.js +0 -115
- package/dist/opencode/core/queryKeySerializer.gen.d.ts +0 -19
- package/dist/opencode/core/queryKeySerializer.gen.js +0 -100
- package/dist/opencode/core/serverSentEvents.gen.d.ts +0 -72
- package/dist/opencode/core/serverSentEvents.gen.js +0 -138
- package/dist/opencode/core/types.gen.d.ts +0 -79
- package/dist/opencode/core/types.gen.js +0 -3
- package/dist/opencode/core/types.gen.js.map +0 -1
- package/dist/opencode/core/utils.gen.d.ts +0 -20
- package/dist/opencode/core/utils.gen.js +0 -88
- package/dist/opencode/index.d.ts +0 -3
- package/dist/opencode/index.d.ts.map +0 -1
- package/dist/opencode/index.js +0 -4
- package/dist/opencode/index.js.map +0 -1
- package/dist/opencode/schemas.gen.d.ts +0 -4823
- package/dist/opencode/schemas.gen.d.ts.map +0 -1
- package/dist/opencode/schemas.gen.js +0 -5816
- package/dist/opencode/schemas.gen.js.map +0 -1
- package/dist/opencode/sdk.gen.d.ts +0 -562
- package/dist/opencode/sdk.gen.d.ts.map +0 -1
- package/dist/opencode/sdk.gen.js +0 -766
- package/dist/opencode/sdk.gen.js.map +0 -1
- package/dist/opencode/types.gen.d.ts +0 -4213
- package/dist/opencode/types.gen.d.ts.map +0 -1
- package/dist/opencode/types.gen.js +0 -25
- package/dist/opencode/types.gen.js.map +0 -1
- package/dist/opencode/zod.gen.d.ts +0 -17243
- package/dist/opencode/zod.gen.d.ts.map +0 -1
- package/dist/opencode/zod.gen.js +0 -2876
- package/dist/opencode/zod.gen.js.map +0 -1
- package/dist/schema/browser.d.ts.map +0 -1
- package/dist/schema/browser.js.map +0 -1
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/client.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/client.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/index.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/index.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/types.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/types.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/utils.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client/utils.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/client.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/auth.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/auth.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/bodySerializer.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/bodySerializer.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/params.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/params.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/pathSerializer.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/pathSerializer.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/queryKeySerializer.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/queryKeySerializer.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/serverSentEvents.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/serverSentEvents.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/types.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/types.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/utils.gen.d.ts +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/core/utils.gen.js +0 -0
- /package/dist/{gomtmapi_v2 → gomtmapi}/types.gen.js +0 -0
- /package/dist/{schema → supabase/schema}/browser.d.ts +0 -0
- /package/dist/{schema → supabase/schema}/browser.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Session } from "@supabase/supabase-js";
|
|
4
|
+
import { createContext, useContext, useEffect, useMemo, useState, type PropsWithChildren, type ReactNode } from "react";
|
|
5
|
+
import { useSupabaseBrowser } from "./context";
|
|
6
|
+
|
|
7
|
+
interface SupabaseAuthContextType {
|
|
8
|
+
session: Session | null;
|
|
9
|
+
token: string | undefined;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const SupabaseAuthContext = createContext<SupabaseAuthContextType | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
export function useSupabaseAuth() {
|
|
16
|
+
const context = useContext(SupabaseAuthContext);
|
|
17
|
+
if (context === undefined) {
|
|
18
|
+
throw new Error("useSupabaseAuth must be used within a SupabaseAuthProvider");
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function SupabaseAuthProvider({ children }: PropsWithChildren): ReactNode {
|
|
24
|
+
const sb = useSupabaseBrowser();
|
|
25
|
+
const [session, setSession] = useState<Session | null>(null);
|
|
26
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
let mounted = true;
|
|
30
|
+
|
|
31
|
+
async function loadSession() {
|
|
32
|
+
const {
|
|
33
|
+
data: { session },
|
|
34
|
+
} = await sb.auth.getSession();
|
|
35
|
+
if (mounted) {
|
|
36
|
+
setSession(session);
|
|
37
|
+
setIsLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
loadSession();
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
data: { subscription },
|
|
44
|
+
} = sb.auth.onAuthStateChange((_event, session) => {
|
|
45
|
+
if (mounted) {
|
|
46
|
+
setSession(session);
|
|
47
|
+
setIsLoading(false);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
mounted = false;
|
|
53
|
+
subscription.unsubscribe();
|
|
54
|
+
};
|
|
55
|
+
}, [sb]);
|
|
56
|
+
|
|
57
|
+
const value = useMemo(
|
|
58
|
+
() => ({
|
|
59
|
+
session,
|
|
60
|
+
token: session?.access_token,
|
|
61
|
+
isLoading,
|
|
62
|
+
}),
|
|
63
|
+
[session, isLoading],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return <SupabaseAuthContext.Provider value={value}>{children}</SupabaseAuthContext.Provider>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createBrowserClient } from "@supabase/ssr";
|
|
4
|
+
import { createContext, type ReactNode, useContext, useMemo } from "react";
|
|
5
|
+
import type { TypedSupabaseClient } from "../types";
|
|
6
|
+
import type { Database } from "../types/database.types";
|
|
7
|
+
|
|
8
|
+
let client: TypedSupabaseClient | undefined;
|
|
9
|
+
|
|
10
|
+
export function getSupabaseBrowserClient(url?: string, key?: string): TypedSupabaseClient {
|
|
11
|
+
if (url && key) {
|
|
12
|
+
return createBrowserClient<Database>(url, key);
|
|
13
|
+
}
|
|
14
|
+
if (!client) {
|
|
15
|
+
client = createBrowserClient<Database>(
|
|
16
|
+
// biome-ignore lint/style/noNonNullAssertion: .
|
|
17
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
18
|
+
// biome-ignore lint/style/noNonNullAssertion: .
|
|
19
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
// biome-ignore lint/style/noNonNullAssertion: 已经确保了初始化
|
|
23
|
+
return client!;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const SupabaseContext = createContext<TypedSupabaseClient | undefined>(undefined);
|
|
27
|
+
|
|
28
|
+
export function useSupabaseContext(): TypedSupabaseClient {
|
|
29
|
+
const ctx = useContext(SupabaseContext);
|
|
30
|
+
if (!ctx) {
|
|
31
|
+
throw new Error("useSupabaseContext must be used within a SupabaseProvider");
|
|
32
|
+
}
|
|
33
|
+
return ctx;
|
|
34
|
+
}
|
|
35
|
+
export const useSupabaseBrowser = useSupabaseContext;
|
|
36
|
+
|
|
37
|
+
interface SupabaseClientProviderProps {
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
publicKey?: string;
|
|
40
|
+
url?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const SupabaseClientProvider = ({ children, publicKey, url }: SupabaseClientProviderProps): ReactNode => {
|
|
44
|
+
const client = useMemo(() => getSupabaseBrowserClient(url, publicKey), [url, publicKey]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SupabaseContext.Provider value={client}>
|
|
48
|
+
{children}
|
|
49
|
+
</SupabaseContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 游标分页工具函数
|
|
3
|
+
*
|
|
4
|
+
* 提供类型安全的游标分页支持,配合 react-query 的 useInfiniteQuery 使用。
|
|
5
|
+
*
|
|
6
|
+
* @module mtmsdk/supabase/cursor-pagination
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 游标类型定义
|
|
11
|
+
*
|
|
12
|
+
* 使用复合游标 (updated_at + id) 确保分页的唯一性和稳定性
|
|
13
|
+
*/
|
|
14
|
+
export interface CursorPagination {
|
|
15
|
+
cursor: string | null; // ISO 时间戳字符串, 如 "2026-01-20T08:00:00Z"
|
|
16
|
+
cursorId: string | null; // UUID 字符串
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 从数据列表中提取下一页游标
|
|
21
|
+
*
|
|
22
|
+
* @param items - 当前页的数据列表
|
|
23
|
+
* @param limit - 每页数量
|
|
24
|
+
* @param cursorField - 游标字段名 (默认 "updated_at")
|
|
25
|
+
* @param idField - ID 字段名 (默认 "id")
|
|
26
|
+
* @returns 下一页游标, 如果没有更多数据则返回 undefined
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({
|
|
31
|
+
* queryKey: ['projects', kw],
|
|
32
|
+
* queryFn: async ({ pageParam }) => {
|
|
33
|
+
* const { data } = await sb.rpc('audit_project_list_cursor', {
|
|
34
|
+
* p_cursor: pageParam?.cursor ?? null,
|
|
35
|
+
* p_cursor_id: pageParam?.cursorId ?? null,
|
|
36
|
+
* p_limit: 20,
|
|
37
|
+
* p_kw: kw
|
|
38
|
+
* });
|
|
39
|
+
* return data ?? [];
|
|
40
|
+
* },
|
|
41
|
+
* getNextPageParam: (lastPage) => getNextCursor(lastPage, 20),
|
|
42
|
+
* initialPageParam: null as CursorPagination | null
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function getNextCursor<
|
|
47
|
+
T extends Record<string, unknown>,
|
|
48
|
+
>(
|
|
49
|
+
items: T[] | null | undefined,
|
|
50
|
+
limit: number,
|
|
51
|
+
cursorField: keyof T = "updated_at" as keyof T,
|
|
52
|
+
idField: keyof T = "id" as keyof T,
|
|
53
|
+
): CursorPagination | undefined {
|
|
54
|
+
// 如果数据为空或数量小于 limit,说明已到达最后一页
|
|
55
|
+
if (!items || items.length < limit) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 获取最后一条记录
|
|
60
|
+
const lastItem = items[items.length - 1];
|
|
61
|
+
if (!lastItem) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const cursorValue = lastItem[cursorField];
|
|
66
|
+
const idValue = lastItem[idField];
|
|
67
|
+
|
|
68
|
+
// 验证游标值有效性
|
|
69
|
+
if (cursorValue === undefined || cursorValue === null) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
cursor: String(cursorValue),
|
|
75
|
+
cursorId: idValue != null ? String(idValue) : null,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 将所有分页数据合并为单一列表
|
|
81
|
+
*
|
|
82
|
+
* @param pages - useInfiniteQuery 返回的 pages 数组
|
|
83
|
+
* @returns 合并后的扁平数据列表
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* const { data } = useInfiniteQuery({ ... });
|
|
88
|
+
* const allProjects = flattenPages(data?.pages);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function flattenPages<T>(
|
|
92
|
+
pages: T[][] | undefined,
|
|
93
|
+
): T[] {
|
|
94
|
+
if (!pages) return [];
|
|
95
|
+
return pages.flat();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 无限滚动分页状态
|
|
100
|
+
*/
|
|
101
|
+
export interface InfiniteScrollState {
|
|
102
|
+
isLoading: boolean;
|
|
103
|
+
isFetchingNextPage: boolean;
|
|
104
|
+
hasNextPage: boolean;
|
|
105
|
+
error: Error | null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 创建 IntersectionObserver 用于无限滚动
|
|
110
|
+
*
|
|
111
|
+
* @param onIntersect - 当元素进入视口时的回调
|
|
112
|
+
* @param options - IntersectionObserver 配置选项
|
|
113
|
+
* @returns cleanup 函数
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* const loadMoreRef = useRef<HTMLDivElement>(null);
|
|
118
|
+
*
|
|
119
|
+
* useEffect(() => {
|
|
120
|
+
* if (!loadMoreRef.current) return;
|
|
121
|
+
* return createInfiniteScrollObserver(
|
|
122
|
+
* () => {
|
|
123
|
+
* if (hasNextPage && !isFetchingNextPage) {
|
|
124
|
+
* fetchNextPage();
|
|
125
|
+
* }
|
|
126
|
+
* },
|
|
127
|
+
* { root: scrollContainerRef.current }
|
|
128
|
+
* )(loadMoreRef.current);
|
|
129
|
+
* }, [hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function createInfiniteScrollObserver(
|
|
133
|
+
onIntersect: () => void,
|
|
134
|
+
options?: IntersectionObserverInit,
|
|
135
|
+
): (element: Element) => () => void {
|
|
136
|
+
return (element: Element) => {
|
|
137
|
+
const observer = new IntersectionObserver((entries) => {
|
|
138
|
+
const [entry] = entries;
|
|
139
|
+
if (entry?.isIntersecting) {
|
|
140
|
+
onIntersect();
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
root: null,
|
|
144
|
+
rootMargin: "100px",
|
|
145
|
+
threshold: 0.1,
|
|
146
|
+
...options,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
observer.observe(element);
|
|
150
|
+
|
|
151
|
+
return () => {
|
|
152
|
+
observer.disconnect();
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
export const zRpcBaseResponse = z.object({
|
|
4
|
+
error: z.object({
|
|
5
|
+
message: z.string(),
|
|
6
|
+
}),
|
|
7
|
+
});
|
|
8
|
+
export const zBrowserUpsertArgs = z
|
|
9
|
+
.object({
|
|
10
|
+
id: z.string().nullish(),//.transform( x => x ?? undefined ),
|
|
11
|
+
title: z.string(),
|
|
12
|
+
profile_id: z.string().nullish(),//.transform( x => x ?? undefined ),
|
|
13
|
+
description: z.string().nullish()//.transform( x => x ?? undefined ),
|
|
14
|
+
})
|
|
15
|
+
.meta({ ref: "BrowserUpsertArgs" });
|
|
16
|
+
|
|
17
|
+
export const zBrowserListReq = z
|
|
18
|
+
.object({
|
|
19
|
+
kw: z.string().optional(),
|
|
20
|
+
})
|
|
21
|
+
.describe("BrowserListReq")
|
|
22
|
+
.meta({ ref: "BrowserListReq" });
|
|
23
|
+
|
|
24
|
+
const zBrowserItem = z
|
|
25
|
+
.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
title: z.string(),
|
|
28
|
+
})
|
|
29
|
+
.describe("BrowserItem")
|
|
30
|
+
.meta({ ref: "BrowserItem" });
|
|
31
|
+
|
|
32
|
+
export const zBrowserData = z
|
|
33
|
+
.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
title: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.describe("BrowserData")
|
|
38
|
+
.meta({ ref: "BrowserData" });
|
|
39
|
+
|
|
40
|
+
export const zBrowserListResponse = zRpcBaseResponse
|
|
41
|
+
.extend({
|
|
42
|
+
data: z.array(zBrowserItem),
|
|
43
|
+
})
|
|
44
|
+
// .describe("BrowserProfileResponse")
|
|
45
|
+
.meta({ ref: "BrowserList" });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
const singleRowPreprocessor = (val: unknown) => {
|
|
4
|
+
if (Array.isArray(val)) {
|
|
5
|
+
if (val.length === 0) return null;
|
|
6
|
+
if (val.length === 1) return val[0];
|
|
7
|
+
}
|
|
8
|
+
return val;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const gatewayUrlConfigSchema = z.preprocess(
|
|
12
|
+
singleRowPreprocessor,
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
mtgate_url: z.string().url({ message: "必须是有效的 URL" }).optional().or(z.literal("")),
|
|
16
|
+
})
|
|
17
|
+
.nullable(),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const domainConfigSchema = z.preprocess(
|
|
21
|
+
singleRowPreprocessor,
|
|
22
|
+
z
|
|
23
|
+
.object({
|
|
24
|
+
primary_domain: z.string().min(1, "主域名不能为空"),
|
|
25
|
+
worker_subdomain_prefix: z.string().optional().default(""),
|
|
26
|
+
})
|
|
27
|
+
.nullable(),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const sharedServerGetSchema = z.preprocess(
|
|
31
|
+
singleRowPreprocessor,
|
|
32
|
+
z
|
|
33
|
+
.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
name: z.string(),
|
|
36
|
+
url: z.string().nullable().optional(),
|
|
37
|
+
is_shared: z.boolean(),
|
|
38
|
+
})
|
|
39
|
+
.nullable(),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const smsProviderConfigSchema = z.object({
|
|
43
|
+
default_provider: z.enum(["manual", "demo"]).optional().default("manual"),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const geminiProxyConfigSchema = z.object({
|
|
47
|
+
default_model: z.string().optional().default("gemini-1.5-pro"),
|
|
48
|
+
model_mapping: z.record(z.string(), z.string()).optional().default({}),
|
|
49
|
+
api_version: z.enum(["v1", "v1beta"]).optional().default("v1"),
|
|
50
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createServerClient } from "@supabase/ssr";
|
|
2
|
+
import type { cookies } from "next/headers";
|
|
3
|
+
import type { Database } from "../types/database.types";
|
|
4
|
+
|
|
5
|
+
export function useSupabaseServer(
|
|
6
|
+
cookieStore: Awaited<ReturnType<typeof cookies>>,
|
|
7
|
+
) {
|
|
8
|
+
return createServerClient<Database>(
|
|
9
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
10
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
11
|
+
{
|
|
12
|
+
cookies: {
|
|
13
|
+
getAll() {
|
|
14
|
+
return cookieStore.getAll();
|
|
15
|
+
},
|
|
16
|
+
setAll(cookiesToSet) {
|
|
17
|
+
try {
|
|
18
|
+
for (const co of cookiesToSet) {
|
|
19
|
+
cookieStore.set(co.name, co.value, co.options);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
//!!! 提示,对于nextjs + honoapi 后端方式使用,可能出现以下错误:
|
|
23
|
+
// Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options
|
|
24
|
+
//可以直接忽略.
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createServerClient, parseCookieHeader } from "@supabase/ssr";
|
|
2
|
+
import { createClient } from "@supabase/supabase-js";
|
|
3
|
+
import type { Context } from "hono";
|
|
4
|
+
import { setCookie } from "hono/cookie";
|
|
5
|
+
import type { TypedSupabaseClient } from "../types";
|
|
6
|
+
|
|
7
|
+
export const getSupabaseUrl = () => {
|
|
8
|
+
if (!process.env.NEXT_PUBLIC_SUPABASE_URL) {
|
|
9
|
+
throw new Error("NEXT_PUBLIC_SUPABASE_URL missing!");
|
|
10
|
+
}
|
|
11
|
+
return process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
12
|
+
};
|
|
13
|
+
export const getSupabasePublicKey = () => {
|
|
14
|
+
if (!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY) {
|
|
15
|
+
throw new Error("NEXT_PUBLIC_SUPABASE_ANON_KEY missing!");
|
|
16
|
+
}
|
|
17
|
+
return process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getSupabaseProjectRef = () => {
|
|
21
|
+
const uri = new URL(getSupabaseUrl());
|
|
22
|
+
const supabasePrject = uri.hostname.split(".")[0];
|
|
23
|
+
return supabasePrject;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getSupabase = (c: Context) => {
|
|
27
|
+
const client: TypedSupabaseClient = createServerClient(getSupabaseUrl(), getSupabasePublicKey(), {
|
|
28
|
+
cookies: {
|
|
29
|
+
//@ts-expect-error
|
|
30
|
+
getAll() {
|
|
31
|
+
return parseCookieHeader(c.req.header("Cookie") ?? "");
|
|
32
|
+
},
|
|
33
|
+
setAll(cookiesToSet) {
|
|
34
|
+
for (const co of cookiesToSet) {
|
|
35
|
+
//@ts-expect-error
|
|
36
|
+
setCookie(c, co.name, co.value, co.options);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
global: {
|
|
41
|
+
// 由于gomtm supabase 客户端已经登录.所以这里直接传递 Authorization 头,即可.
|
|
42
|
+
headers: {
|
|
43
|
+
...(c.req.header("Authorization") && {
|
|
44
|
+
Authorization: c.req.header("Authorization"),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return client;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const getSupabaseAdmin = () => {
|
|
53
|
+
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
54
|
+
if (!serviceRoleKey) {
|
|
55
|
+
throw new Error("require SUPABASE_SERVICE_ROLE_KEY");
|
|
56
|
+
}
|
|
57
|
+
const client: TypedSupabaseClient = createClient(getSupabaseUrl(), serviceRoleKey, {
|
|
58
|
+
auth: {
|
|
59
|
+
autoRefreshToken: false,
|
|
60
|
+
persistSession: false,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return client;
|
|
65
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AnyPostgrestResponse,
|
|
3
|
+
isPostgrestBuilder,
|
|
4
|
+
isPostgrestTransformBuilder,
|
|
5
|
+
} from "@supabase-cache-helpers/postgrest-core";
|
|
6
|
+
import type { PostgrestError } from "@supabase/postgrest-js";
|
|
7
|
+
import type {
|
|
8
|
+
UseQueryOptions as UseReactQueryOptions,
|
|
9
|
+
UseSuspenseQueryOptions,
|
|
10
|
+
} from "@tanstack/react-query";
|
|
11
|
+
|
|
12
|
+
import { encode } from "./key";
|
|
13
|
+
|
|
14
|
+
export function buildQueryOpts<Result>(
|
|
15
|
+
query: PromiseLike<AnyPostgrestResponse<Result>>,
|
|
16
|
+
config?: Omit<
|
|
17
|
+
UseReactQueryOptions<AnyPostgrestResponse<Result>, PostgrestError>,
|
|
18
|
+
"queryKey" | "queryFn"
|
|
19
|
+
>,
|
|
20
|
+
): UseReactQueryOptions<AnyPostgrestResponse<Result>, PostgrestError> {
|
|
21
|
+
return {
|
|
22
|
+
queryKey: encode<Result>(query, false),
|
|
23
|
+
queryFn: async ({ signal }) => {
|
|
24
|
+
if (isPostgrestTransformBuilder(query)) {
|
|
25
|
+
query = query.abortSignal(signal);
|
|
26
|
+
}
|
|
27
|
+
if (isPostgrestBuilder(query)) {
|
|
28
|
+
query = query.throwOnError();
|
|
29
|
+
}
|
|
30
|
+
return await query;
|
|
31
|
+
},
|
|
32
|
+
...config,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function buildSuspenseQueryOpts<Result>(
|
|
37
|
+
query: PromiseLike<AnyPostgrestResponse<Result>>,
|
|
38
|
+
config?: Omit<
|
|
39
|
+
UseSuspenseQueryOptions<AnyPostgrestResponse<Result>, PostgrestError>,
|
|
40
|
+
"queryKey" | "queryFn"
|
|
41
|
+
>,
|
|
42
|
+
): UseSuspenseQueryOptions<AnyPostgrestResponse<Result>, PostgrestError> {
|
|
43
|
+
return {
|
|
44
|
+
queryKey: encode<Result>(query, false),
|
|
45
|
+
queryFn: async ({ signal }) => {
|
|
46
|
+
if (isPostgrestTransformBuilder(query)) {
|
|
47
|
+
query = query.abortSignal(signal);
|
|
48
|
+
}
|
|
49
|
+
if (isPostgrestBuilder(query)) {
|
|
50
|
+
query = query.throwOnError();
|
|
51
|
+
}
|
|
52
|
+
return await query;
|
|
53
|
+
},
|
|
54
|
+
...config,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type DecodedKey, isPostgrestBuilder, PostgrestParser } from "@supabase-cache-helpers/postgrest-core";
|
|
2
|
+
|
|
3
|
+
export const KEY_PREFIX = "postgrest";
|
|
4
|
+
export const INFINITE_KEY_PREFIX = "page";
|
|
5
|
+
|
|
6
|
+
export type DecodedReactQueryKey = DecodedKey & {
|
|
7
|
+
isInfinite: boolean;
|
|
8
|
+
key: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const encode = <Result>(key: unknown, isInfinite: boolean): string[] => {
|
|
12
|
+
if (!isPostgrestBuilder<Result>(key)) {
|
|
13
|
+
throw new Error("Key is not a PostgrestBuilder");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const parser = new PostgrestParser<Result>(key);
|
|
17
|
+
return [
|
|
18
|
+
KEY_PREFIX,
|
|
19
|
+
isInfinite ? INFINITE_KEY_PREFIX : "null",
|
|
20
|
+
parser.schema,
|
|
21
|
+
parser.table,
|
|
22
|
+
parser.queryKey,
|
|
23
|
+
parser.bodyKey ?? "null",
|
|
24
|
+
`count=${parser.count}`,
|
|
25
|
+
`head=${parser.isHead}`,
|
|
26
|
+
parser.orderByKey,
|
|
27
|
+
];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const decode = (key: unknown): DecodedReactQueryKey | null => {
|
|
31
|
+
if (!Array.isArray(key)) return null;
|
|
32
|
+
|
|
33
|
+
const [prefix, infinitePrefix, schema, table, queryKey, bodyKey, count, head, orderByKey] = key;
|
|
34
|
+
|
|
35
|
+
// Exit early if not a postgrest key
|
|
36
|
+
if (prefix !== KEY_PREFIX) return null;
|
|
37
|
+
|
|
38
|
+
const params = new URLSearchParams(queryKey);
|
|
39
|
+
const limit = params.get("limit");
|
|
40
|
+
const offset = params.get("offset");
|
|
41
|
+
|
|
42
|
+
const countValue = count.replace("count=", "");
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
limit: limit ? Number(limit) : undefined,
|
|
46
|
+
offset: offset ? Number(offset) : undefined,
|
|
47
|
+
bodyKey,
|
|
48
|
+
count: countValue === "null" ? null : countValue,
|
|
49
|
+
isHead: head === "head=true",
|
|
50
|
+
isInfinite: infinitePrefix === INFINITE_KEY_PREFIX,
|
|
51
|
+
key,
|
|
52
|
+
queryKey,
|
|
53
|
+
schema,
|
|
54
|
+
table,
|
|
55
|
+
orderByKey,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type AnyPostgrestResponse, isPostgrestBuilder } from "@supabase-cache-helpers/postgrest-core";
|
|
2
|
+
import type {
|
|
3
|
+
PostgrestError,
|
|
4
|
+
PostgrestMaybeSingleResponse,
|
|
5
|
+
PostgrestResponse,
|
|
6
|
+
PostgrestSingleResponse,
|
|
7
|
+
} from "@supabase/postgrest-js";
|
|
8
|
+
import type { FetchQueryOptions, QueryClient } from "@tanstack/react-query";
|
|
9
|
+
import { buildQueryOpts } from "./build-query-opts";
|
|
10
|
+
import { encode } from "./key";
|
|
11
|
+
|
|
12
|
+
function prefetchQuery<Result>(
|
|
13
|
+
queryClient: QueryClient,
|
|
14
|
+
query: PromiseLike<PostgrestSingleResponse<Result>>,
|
|
15
|
+
config?: Omit<FetchQueryOptions<PostgrestSingleResponse<Result>, PostgrestError>, "queryKey" | "queryFn">,
|
|
16
|
+
): Promise<void>;
|
|
17
|
+
function prefetchQuery<Result>(
|
|
18
|
+
queryClient: QueryClient,
|
|
19
|
+
query: PromiseLike<PostgrestMaybeSingleResponse<Result>>,
|
|
20
|
+
config?: Omit<FetchQueryOptions<PostgrestMaybeSingleResponse<Result>, PostgrestError>, "queryKey" | "queryFn">,
|
|
21
|
+
): Promise<void>;
|
|
22
|
+
function prefetchQuery<Result>(
|
|
23
|
+
queryClient: QueryClient,
|
|
24
|
+
query: PromiseLike<PostgrestResponse<Result>>,
|
|
25
|
+
config?: Omit<FetchQueryOptions<PostgrestResponse<Result>, PostgrestError>, "queryKey" | "queryFn">,
|
|
26
|
+
): Promise<void>;
|
|
27
|
+
|
|
28
|
+
async function prefetchQuery<Result>(
|
|
29
|
+
queryClient: QueryClient,
|
|
30
|
+
query: PromiseLike<AnyPostgrestResponse<Result>>,
|
|
31
|
+
config?: Omit<FetchQueryOptions<AnyPostgrestResponse<Result>, PostgrestError>, "queryKey" | "queryFn">,
|
|
32
|
+
) {
|
|
33
|
+
await queryClient.prefetchQuery<AnyPostgrestResponse<Result>, PostgrestError>(buildQueryOpts(query, config));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function fetchQueryInitialData<Result>(
|
|
37
|
+
query: PromiseLike<PostgrestSingleResponse<Result>>,
|
|
38
|
+
): Promise<[string[], PostgrestSingleResponse<Result>]>;
|
|
39
|
+
|
|
40
|
+
function fetchQueryInitialData<Result>(
|
|
41
|
+
query: PromiseLike<PostgrestMaybeSingleResponse<Result>>,
|
|
42
|
+
): Promise<[string[], PostgrestMaybeSingleResponse<Result>]>;
|
|
43
|
+
|
|
44
|
+
function fetchQueryInitialData<Result>(
|
|
45
|
+
query: PromiseLike<PostgrestResponse<Result>>,
|
|
46
|
+
): Promise<[string[], PostgrestResponse<Result>]>;
|
|
47
|
+
|
|
48
|
+
async function fetchQueryInitialData<Result>(
|
|
49
|
+
query: PromiseLike<AnyPostgrestResponse<Result>>,
|
|
50
|
+
): Promise<[string[], AnyPostgrestResponse<Result>]> {
|
|
51
|
+
if (!isPostgrestBuilder<Result>(query)) {
|
|
52
|
+
throw new Error("Query is not a PostgrestBuilder");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return [encode(query, false), await query.throwOnError()];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { fetchQueryInitialData, prefetchQuery };
|
|
59
|
+
|