@playdrop/playdrop-cli 0.3.1-build.1 → 0.3.5-build.1
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/README.md +60 -22
- package/config/client-meta.json +5 -5
- package/dist/apps/build.js +90 -114
- package/dist/apps/upload.js +35 -11
- package/dist/apps/validate.js +61 -0
- package/dist/assets/model-artifacts.d.ts +8 -0
- package/dist/assets/model-artifacts.js +375 -0
- package/dist/assets/model-worker.d.ts +22 -0
- package/dist/assets/model-worker.js +123 -0
- package/dist/catalogue.d.ts +10 -4
- package/dist/catalogue.js +272 -45
- package/dist/commandContext.d.ts +1 -0
- package/dist/commandContext.js +45 -15
- package/dist/commands/browse.d.ts +16 -0
- package/dist/commands/browse.js +370 -0
- package/dist/commands/build.js +12 -4
- package/dist/commands/capture.js +24 -24
- package/dist/commands/captureRemote.d.ts +11 -0
- package/dist/commands/captureRemote.js +90 -0
- package/dist/commands/comments.d.ts +14 -0
- package/dist/commands/comments.js +189 -0
- package/dist/commands/create.js +112 -72
- package/dist/commands/creations.d.ts +49 -0
- package/dist/commands/creations.js +657 -0
- package/dist/commands/credits.d.ts +10 -0
- package/dist/commands/credits.js +91 -0
- package/dist/commands/detail.d.ts +2 -2
- package/dist/commands/detail.js +148 -290
- package/dist/commands/dev.js +26 -24
- package/dist/commands/devServer.js +88 -9
- package/dist/commands/devShared.js +2 -2
- package/dist/commands/documentation.d.ts +4 -1
- package/dist/commands/documentation.js +79 -104
- package/dist/commands/feedback.d.ts +12 -9
- package/dist/commands/feedback.js +125 -257
- package/dist/commands/format.js +6 -13
- package/dist/commands/generation.d.ts +11 -0
- package/dist/commands/generation.js +329 -43
- package/dist/commands/gettingStarted.d.ts +1 -0
- package/dist/commands/gettingStarted.js +26 -0
- package/dist/commands/init.js +26 -24
- package/dist/commands/login.js +9 -8
- package/dist/commands/logout.js +2 -1
- package/dist/commands/notifications.d.ts +14 -0
- package/dist/commands/notifications.js +179 -0
- package/dist/commands/search.d.ts +13 -0
- package/dist/commands/search.js +198 -0
- package/dist/commands/upload.js +83 -35
- package/dist/commands/validate.js +15 -1
- package/dist/commands/versionsBrowse.d.ts +7 -0
- package/dist/commands/versionsBrowse.js +209 -0
- package/dist/commands/whoami.js +9 -8
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +52 -0
- package/dist/externalAssetPackValidation.d.ts +2 -0
- package/dist/externalAssetPackValidation.js +115 -0
- package/dist/http.js +1 -1
- package/dist/index.js +570 -629
- package/dist/messages.js +11 -11
- package/dist/output.d.ts +5 -0
- package/dist/output.js +45 -0
- package/dist/playwright.js +10 -2
- package/dist/refs.d.ts +18 -0
- package/dist/refs.js +105 -0
- package/node_modules/@playdrop/ai-client/dist/index.d.ts +43 -16
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/ai-client/package.json +1 -0
- package/node_modules/@playdrop/api-client/dist/client.d.ts +77 -43
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +379 -1574
- package/node_modules/@playdrop/api-client/dist/core/errors.d.ts +9 -0
- package/node_modules/@playdrop/api-client/dist/core/errors.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/core/errors.js +46 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts +27 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/core/request.js +122 -0
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts +75 -0
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +282 -0
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +22 -0
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/ai.js +15 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +60 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +301 -0
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts +59 -0
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +297 -0
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +62 -0
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +297 -0
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts +28 -0
- package/node_modules/@playdrop/api-client/dist/domains/auth.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/auth.js +78 -0
- package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts +29 -0
- package/node_modules/@playdrop/api-client/dist/domains/comments.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/comments.js +65 -0
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts +24 -0
- package/node_modules/@playdrop/api-client/dist/domains/me.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/me.js +35 -0
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts +37 -0
- package/node_modules/@playdrop/api-client/dist/domains/payments.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/payments.js +148 -0
- package/node_modules/@playdrop/api-client/dist/domains/search.d.ts +27 -0
- package/node_modules/@playdrop/api-client/dist/domains/search.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/search.js +65 -0
- package/node_modules/@playdrop/api-client/dist/index.d.ts +59 -60
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +142 -53
- package/node_modules/@playdrop/api-client/package.json +3 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/entity-cleaner.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/entity-utils.d.ts +8 -8
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/common.d.ts +2 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/common.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/textured-builder.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.d.ts +6 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/voxel-builder.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/builder.d.ts +3 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/templates/index.d.ts +4 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/palette_tools.d.ts +4 -4
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.d.ts +4 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/serialization.js +10 -10
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/serialization.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/textures.d.ts +5 -5
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/textures.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/infer-face.d.ts +2 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/layer-mode.d.ts +2 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/layer-mode.js +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +2 -0
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/slice.d.ts +2 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/slice.js +1 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.d.ts +3 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/upscale.js +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/upscale.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/slice.d.ts +2 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/slice.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/types.d.ts +3 -3
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/validation.d.ts +10 -10
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/validation.js +36 -36
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/validation.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/test/entity-utils.test.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/index.test.js +2 -2
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/index.test.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/test/layer-mode.test.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/test/palette-tools.test.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/serialization.test.js +6 -6
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/serialization.test.js.map +1 -1
- package/node_modules/@playdrop/boxel-core/dist/test/textures.test.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/types.test.js +1 -1
- package/node_modules/@playdrop/boxel-core/dist/test/types.test.js.map +1 -0
- package/node_modules/@playdrop/boxel-core/dist/test/upscale.test.js.map +1 -0
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/validation.test.js +11 -11
- package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/validation.test.js.map +1 -1
- package/node_modules/@playdrop/{entity-core → boxel-core}/package.json +3 -3
- package/node_modules/@playdrop/boxel-three/dist/src/animations.d.ts +4 -0
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/animations.js +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/builders.d.ts +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/builders.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/context.d.ts +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/exporters/glb.d.ts +9 -9
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/exporters/glb.js +4 -4
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/exporters/image.d.ts +4 -4
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/exporters/image.js +5 -5
- package/node_modules/@playdrop/boxel-three/dist/src/index.d.ts +17 -0
- package/node_modules/@playdrop/boxel-three/dist/src/index.js +15 -0
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/instantiate.d.ts +4 -4
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/instantiate.js +4 -4
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/nodes.d.ts +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.d.ts +7 -0
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/overlays.js +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/scene.d.ts +3 -0
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/scene.js +6 -6
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/skinned-mesh.d.ts +2 -2
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/textures.d.ts +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/textures.js +2 -2
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/types.d.ts +15 -15
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/voxels/faces.d.ts +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/voxels/mesher.d.ts +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/voxels/mesher.js +1 -1
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/export-image.playwright.test.js +4 -4
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/fixtures/render-worker.d.ts +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/fixtures/render-worker.js +10 -10
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/glb-skinned.test.js +6 -6
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +8 -0
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/instantiate.test.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/overlays.test.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/scene-filter.test.js +5 -5
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/scene-smoke.test.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/skinned-mesh.test.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/textured-overlay.test.js +3 -3
- package/node_modules/@playdrop/{entity-three → boxel-three}/package.json +5 -4
- package/node_modules/@playdrop/config/client-meta.json +5 -5
- package/node_modules/@playdrop/config/dist/src/constants.d.ts +5 -0
- package/node_modules/@playdrop/config/dist/src/constants.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/constants.js +5 -1
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/config/package.json +1 -1
- package/node_modules/@playdrop/types/dist/api.d.ts +326 -62
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.js +56 -0
- package/node_modules/@playdrop/types/dist/app.d.ts +0 -14
- package/node_modules/@playdrop/types/dist/app.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/app.js +0 -10
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +12 -1
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.d.ts +85 -4
- package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.js +43 -37
- package/node_modules/@playdrop/types/dist/entity.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/entity.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/entity.js +2 -2
- package/node_modules/@playdrop/types/dist/realtime.d.ts +27 -26
- package/node_modules/@playdrop/types/dist/realtime.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/version.d.ts +5 -0
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/package.json +11 -9
- package/bin/playdrop-cli +0 -2
- package/dist/commands/asset-packs.d.ts +0 -27
- package/dist/commands/asset-packs.js +0 -508
- package/dist/commands/assets.d.ts +0 -35
- package/dist/commands/assets.js +0 -668
- package/dist/commands/list.d.ts +0 -7
- package/dist/commands/list.js +0 -347
- package/dist/commands/migrateCatalogueV2.d.ts +0 -1
- package/dist/commands/migrateCatalogueV2.js +0 -142
- package/dist/commands/versions.d.ts +0 -17
- package/dist/commands/versions.js +0 -384
- package/node_modules/@playdrop/entity-core/dist/src/entity-cleaner.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/entity-utils.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/humanoid/r15/textured-builder.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/humanoid/r15/types.d.ts +0 -6
- package/node_modules/@playdrop/entity-core/dist/src/humanoid/r15/voxel-builder.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/humanoid/r6/builder.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/humanoid/templates/index.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/palette_tools.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/serialization.d.ts +0 -4
- package/node_modules/@playdrop/entity-core/dist/src/transforms/textured-boxes/infer-face.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/transforms/textured-boxes/layer-mode.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +0 -2
- package/node_modules/@playdrop/entity-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/transforms/textured-boxes/slice.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/src/transforms/upscale.d.ts +0 -3
- package/node_modules/@playdrop/entity-core/dist/test/entity-utils.test.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/test/layer-mode.test.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/test/palette-tools.test.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/test/textures.test.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/test/types.test.js.map +0 -1
- package/node_modules/@playdrop/entity-core/dist/test/upscale.test.js.map +0 -1
- package/node_modules/@playdrop/entity-three/dist/src/animations.d.ts +0 -4
- package/node_modules/@playdrop/entity-three/dist/src/index.d.ts +0 -17
- package/node_modules/@playdrop/entity-three/dist/src/index.js +0 -15
- package/node_modules/@playdrop/entity-three/dist/src/overlays.d.ts +0 -7
- package/node_modules/@playdrop/entity-three/dist/src/scene.d.ts +0 -3
- package/node_modules/@playdrop/entity-three/dist/test/index.test.js +0 -8
- package/node_modules/@playdrop/types/dist/profile-asset-semantics.d.ts +0 -22
- package/node_modules/@playdrop/types/dist/profile-asset-semantics.d.ts.map +0 -1
- package/node_modules/@playdrop/types/dist/profile-asset-semantics.js +0 -105
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/entity-cleaner.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/entity-utils.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/format-utils.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/format-utils.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/format-utils.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/geometry.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/geometry.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/geometry.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/index.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/index.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/index.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/common.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/index.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/index.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/index.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/textured-builder.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/types.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/types.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r15/voxel-builder.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/builder.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/index.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/index.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/index.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/scanner.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/scanner.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/scanner.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/artifacts.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/artifacts.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/artifacts.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/face-map.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/face-map.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/r6/textures/face-map.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/templates/humanoid_r15.json +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/templates/humanoid_r6.json +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/humanoid/templates/index.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/index.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/index.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/index.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/materials.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/materials.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/materials.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/palette_tools.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/textures.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/infer-face.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/textured-boxes/merge-overlay.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/slice.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/textured-to-voxel.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/textured-to-voxel.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/transforms/voxels/textured-to-voxel.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/types.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/types.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels/greedy-mesher.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels/greedy-mesher.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels/greedy-mesher.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/src/voxels.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/entity-utils.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/entity-utils.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/greedy-mesher.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/greedy-mesher.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/greedy-mesher.test.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/humanoid/humanoid-builders.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/humanoid/humanoid-builders.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/humanoid/humanoid-builders.test.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/index.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/layer-mode.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/layer-mode.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/materials.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/materials.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/materials.test.js.map +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/palette-tools.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/palette-tools.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/serialization.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/textures.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/textures.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/types.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/upscale.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/upscale.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/validation.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/voxels.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/voxels.test.js +0 -0
- /package/node_modules/@playdrop/{entity-core → boxel-core}/dist/test/voxels.test.js.map +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/context.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/nodes.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/primitives.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/primitives.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/skinned-mesh.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/texture-atlas.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/texture-atlas.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/types.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/src/voxels/faces.js +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/export-image.playwright.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/glb-skinned.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/index.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/instantiate.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/overlays.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/scene-filter.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/scene-smoke.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/skinned-mesh.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/textured-overlay.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/voxels.test.d.ts +0 -0
- /package/node_modules/@playdrop/{entity-three → boxel-three}/dist/test/voxels.test.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UnsupportedClientError } from '@playdrop/types/api';
|
|
2
|
+
export type ApiResponseLike<T> = {
|
|
3
|
+
status: number;
|
|
4
|
+
body: T;
|
|
5
|
+
headers: Headers;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseUnsupportedError(status: number, payload: unknown): UnsupportedClientError | null;
|
|
8
|
+
export declare function handleApiError(response: ApiResponseLike<any>, context: string): never;
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CAuBrG;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAyBrF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ApiError, UnsupportedClientError } from '@playdrop/types/api';
|
|
2
|
+
export function parseUnsupportedError(status, payload) {
|
|
3
|
+
if (status !== 426 && status !== 400) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const data = (payload && typeof payload === 'object') ? payload : null;
|
|
7
|
+
const code = typeof data?.error === 'string' ? data.error : undefined;
|
|
8
|
+
const unsupportedCodes = new Set([
|
|
9
|
+
'unsupported_client',
|
|
10
|
+
'unsupported_client_version',
|
|
11
|
+
'unsupported_client_build',
|
|
12
|
+
'unsupported_platform_version',
|
|
13
|
+
'missing_client_metadata',
|
|
14
|
+
]);
|
|
15
|
+
const isGuardResponse = status === 426 || (status === 400 && code !== undefined && unsupportedCodes.has(code));
|
|
16
|
+
if (!isGuardResponse) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const message = typeof data?.message === 'string' ? data.message : 'Unsupported client version';
|
|
20
|
+
return new UnsupportedClientError(code ?? 'unsupported_client', message, data ?? null);
|
|
21
|
+
}
|
|
22
|
+
export function handleApiError(response, context) {
|
|
23
|
+
const unsupported = parseUnsupportedError(response.status, response.body);
|
|
24
|
+
if (unsupported) {
|
|
25
|
+
throw unsupported;
|
|
26
|
+
}
|
|
27
|
+
const payload = response.body && typeof response.body === 'object' ? response.body : {};
|
|
28
|
+
const code = typeof payload.error === 'string' ? payload.error : context;
|
|
29
|
+
let message;
|
|
30
|
+
if (typeof payload.message === 'string') {
|
|
31
|
+
message = payload.message;
|
|
32
|
+
}
|
|
33
|
+
else if (typeof payload.error === 'string') {
|
|
34
|
+
message = payload.error;
|
|
35
|
+
if (typeof payload.errorPath === 'string') {
|
|
36
|
+
message = `${payload.error}: ${payload.errorPath}`;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(payload.missing) && payload.missing.length > 0) {
|
|
39
|
+
message = `${payload.error}: missing exports [${payload.missing.join(', ')}]`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
message = `${context} failed`;
|
|
44
|
+
}
|
|
45
|
+
throw new ApiError(message, response.status, code);
|
|
46
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ApiRequestLike = {
|
|
2
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3
|
+
path: string;
|
|
4
|
+
body?: unknown;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export type ApiResponseLike<T> = {
|
|
8
|
+
status: number;
|
|
9
|
+
body: T;
|
|
10
|
+
headers: Headers;
|
|
11
|
+
};
|
|
12
|
+
export type RequestExecutor = <T>(request: ApiRequestLike) => Promise<ApiResponseLike<T>>;
|
|
13
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
14
|
+
export declare function resolveRequestTimeoutMs(value: number | undefined): number;
|
|
15
|
+
export declare function createBaseUrlResolver(baseUrl: string | undefined): () => string;
|
|
16
|
+
export declare function resolveUrl(base: string, path: string): string;
|
|
17
|
+
export declare function parseResponseBody<T>(response: Response): Promise<T>;
|
|
18
|
+
export declare function createRequestExecutor(input: {
|
|
19
|
+
fetchImpl: typeof fetch;
|
|
20
|
+
resolveBaseUrl: () => string;
|
|
21
|
+
resolveUrl: (base: string, path: string) => string;
|
|
22
|
+
parseResponseBody: <T>(response: Response) => Promise<T>;
|
|
23
|
+
resolveToken: () => Promise<string | null>;
|
|
24
|
+
getClientHeaders: () => Record<string, string>;
|
|
25
|
+
requestTimeoutMs: number;
|
|
26
|
+
}): RequestExecutor;
|
|
27
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1F,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAEhD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CASzE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,MAAM,CAqB/E;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7D;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBzE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,iBAAiB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACzD,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,gBAAgB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,eAAe,CAyElB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
2
|
+
export function resolveRequestTimeoutMs(value) {
|
|
3
|
+
if (value === undefined) {
|
|
4
|
+
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
5
|
+
}
|
|
6
|
+
const parsed = Number(value);
|
|
7
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
8
|
+
throw new Error('invalid_api_request_timeout_ms');
|
|
9
|
+
}
|
|
10
|
+
return Math.floor(parsed);
|
|
11
|
+
}
|
|
12
|
+
export function createBaseUrlResolver(baseUrl) {
|
|
13
|
+
return () => {
|
|
14
|
+
if (baseUrl) {
|
|
15
|
+
return baseUrl;
|
|
16
|
+
}
|
|
17
|
+
if (typeof process !== 'undefined' && process.env.NEXT_PUBLIC_API_BASE) {
|
|
18
|
+
return process.env.NEXT_PUBLIC_API_BASE;
|
|
19
|
+
}
|
|
20
|
+
if (typeof window !== 'undefined') {
|
|
21
|
+
const { protocol, hostname } = window.location;
|
|
22
|
+
if (hostname.includes('www.') && hostname.includes('.')) {
|
|
23
|
+
return `${protocol}//api.${hostname.replace('www.', '')}`;
|
|
24
|
+
}
|
|
25
|
+
if (hostname === 'play.local' || hostname === 'www.localhost') {
|
|
26
|
+
const apiDomain = hostname.includes('localhost') ? 'api.localhost' : 'api.local';
|
|
27
|
+
return `${protocol}//${apiDomain}`;
|
|
28
|
+
}
|
|
29
|
+
return `${protocol}//${hostname}:4000`;
|
|
30
|
+
}
|
|
31
|
+
return 'http://localhost:4000';
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function resolveUrl(base, path) {
|
|
35
|
+
if (/^https?:/i.test(path)) {
|
|
36
|
+
return path;
|
|
37
|
+
}
|
|
38
|
+
const normalizedBase = base.endsWith('/') ? base : `${base}/`;
|
|
39
|
+
const trimmedPath = path.startsWith('/') ? path.slice(1) : path;
|
|
40
|
+
return new URL(trimmedPath, normalizedBase).toString();
|
|
41
|
+
}
|
|
42
|
+
export async function parseResponseBody(response) {
|
|
43
|
+
if (response.status === 204 || response.status === 205 || response.status === 304) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const contentType = response.headers.get('content-type') || '';
|
|
47
|
+
if (contentType.includes('application/json')) {
|
|
48
|
+
try {
|
|
49
|
+
return (await response.clone().json());
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// fall through to text if parsing fails
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const text = await response.clone().text();
|
|
57
|
+
return text;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function createRequestExecutor(input) {
|
|
64
|
+
const { fetchImpl, resolveBaseUrl, resolveUrl: resolveUrlInput, parseResponseBody: parseResponseBodyInput, resolveToken, getClientHeaders, requestTimeoutMs, } = input;
|
|
65
|
+
return async function request(req) {
|
|
66
|
+
const base = resolveBaseUrl();
|
|
67
|
+
const targetUrl = resolveUrlInput(base, req.path);
|
|
68
|
+
const headers = new Headers();
|
|
69
|
+
for (const [key, value] of Object.entries(getClientHeaders())) {
|
|
70
|
+
headers.set(key, value);
|
|
71
|
+
}
|
|
72
|
+
headers.set('accept', 'application/json');
|
|
73
|
+
if (req.body !== undefined && req.body !== null && req.method !== 'GET') {
|
|
74
|
+
headers.set('content-type', 'application/json');
|
|
75
|
+
}
|
|
76
|
+
if (req.headers) {
|
|
77
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
78
|
+
headers.set(key, value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const token = await resolveToken();
|
|
82
|
+
if (token) {
|
|
83
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
84
|
+
}
|
|
85
|
+
const init = {
|
|
86
|
+
method: req.method,
|
|
87
|
+
headers,
|
|
88
|
+
};
|
|
89
|
+
if (req.body !== undefined && req.body !== null && req.method !== 'GET') {
|
|
90
|
+
init.body = typeof req.body === 'string' ? req.body : JSON.stringify(req.body);
|
|
91
|
+
}
|
|
92
|
+
let timeoutHandle = null;
|
|
93
|
+
let controller = null;
|
|
94
|
+
if (typeof AbortController !== 'undefined') {
|
|
95
|
+
controller = new AbortController();
|
|
96
|
+
init.signal = controller.signal;
|
|
97
|
+
timeoutHandle = setTimeout(() => {
|
|
98
|
+
controller?.abort();
|
|
99
|
+
}, requestTimeoutMs);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetchImpl(targetUrl, init);
|
|
103
|
+
const parsed = await parseResponseBodyInput(response);
|
|
104
|
+
return {
|
|
105
|
+
status: response.status,
|
|
106
|
+
body: parsed,
|
|
107
|
+
headers: response.headers,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (controller?.signal.aborted) {
|
|
112
|
+
throw new Error(`api_request_timeout:${req.method}:${req.path}`);
|
|
113
|
+
}
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
if (timeoutHandle) {
|
|
118
|
+
clearTimeout(timeoutHandle);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { AdminAppsListResponse, AdminCreditTransactionsResponse, AdminPaymentDetailResponse, AdminPaymentsListResponse, AdminRefundPaymentRequest, AdminUpdateAppRequest, AdminUpdateAppResponse, AdminUserResponse, BatchCreateUsersResponse, CreateUserRequest, CreateUserResponse, CreditPackResponse, CreditPacksResponse, DeleteAdminUserResponse, DeleteAppResponse, AiGenerationDetailResponse, AiGenerationsResponse, PaymentProvider, PaymentStatus, UpdateAdminUserRequest, UsersListResponse } from '@playdrop/types';
|
|
2
|
+
type ApiResponseLike<T> = {
|
|
3
|
+
status: number;
|
|
4
|
+
body: T;
|
|
5
|
+
headers: Headers;
|
|
6
|
+
};
|
|
7
|
+
type RequestExecutor = <T>(input: {
|
|
8
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
9
|
+
path: string;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}) => Promise<ApiResponseLike<T>>;
|
|
14
|
+
type ErrorHandler = (response: ApiResponseLike<unknown>, defaultMessage: string) => never;
|
|
15
|
+
type ParseResponseBody = <T>(response: Response) => Promise<T>;
|
|
16
|
+
export declare function buildAdminApiClientMethods(input: {
|
|
17
|
+
request: RequestExecutor;
|
|
18
|
+
handleApiError: ErrorHandler;
|
|
19
|
+
fetchImpl: typeof fetch;
|
|
20
|
+
resolveBaseUrl: () => string;
|
|
21
|
+
resolveUrl: (base: string, path: string) => string;
|
|
22
|
+
parseResponseBody: ParseResponseBody;
|
|
23
|
+
resolveToken: () => Promise<string | null>;
|
|
24
|
+
getClientHeaders: () => Record<string, string>;
|
|
25
|
+
}): {
|
|
26
|
+
fetchUsers(): Promise<UsersListResponse>;
|
|
27
|
+
createUser(userRequest: CreateUserRequest): Promise<CreateUserResponse>;
|
|
28
|
+
batchCreateUsersFromCsv(formData: FormData): Promise<BatchCreateUsersResponse>;
|
|
29
|
+
fetchAdminUser(userId: number): Promise<AdminUserResponse>;
|
|
30
|
+
updateAdminUser(userId: number, updateRequest: UpdateAdminUserRequest): Promise<AdminUserResponse>;
|
|
31
|
+
deleteAdminUser(userId: number): Promise<DeleteAdminUserResponse>;
|
|
32
|
+
fetchAdminApps(): Promise<AdminAppsListResponse>;
|
|
33
|
+
updateAdminApp(id: number, updateRequest: AdminUpdateAppRequest): Promise<AdminUpdateAppResponse>;
|
|
34
|
+
deleteAdminApp(id: number): Promise<DeleteAppResponse>;
|
|
35
|
+
fetchAdminCreditPacks(): Promise<CreditPacksResponse>;
|
|
36
|
+
createAdminCreditPack(body: {
|
|
37
|
+
sku: string;
|
|
38
|
+
displayName: string;
|
|
39
|
+
amount: number;
|
|
40
|
+
costCents: number;
|
|
41
|
+
}): Promise<CreditPackResponse>;
|
|
42
|
+
updateAdminCreditPack(sku: string, body: {
|
|
43
|
+
displayName?: string;
|
|
44
|
+
amount?: number;
|
|
45
|
+
costCents?: number;
|
|
46
|
+
}): Promise<CreditPackResponse>;
|
|
47
|
+
deleteAdminCreditPack(sku: string): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
syncAdminCreditPacksStripe(): Promise<CreditPacksResponse>;
|
|
51
|
+
fetchAdminPayments(options?: {
|
|
52
|
+
provider?: PaymentProvider;
|
|
53
|
+
status?: PaymentStatus | PaymentStatus[];
|
|
54
|
+
userId?: number;
|
|
55
|
+
creditPackSku?: string;
|
|
56
|
+
from?: string | Date;
|
|
57
|
+
to?: string | Date;
|
|
58
|
+
limit?: number;
|
|
59
|
+
offset?: number;
|
|
60
|
+
}): Promise<AdminPaymentsListResponse>;
|
|
61
|
+
fetchAdminPayment(paymentId: number): Promise<AdminPaymentDetailResponse>;
|
|
62
|
+
refundAdminPayment(paymentId: number, body: AdminRefundPaymentRequest): Promise<AdminPaymentDetailResponse>;
|
|
63
|
+
reconcileAdminPayment(paymentId: number): Promise<AdminPaymentDetailResponse>;
|
|
64
|
+
fetchAdminCreditTransactions(options?: {
|
|
65
|
+
limit?: number;
|
|
66
|
+
offset?: number;
|
|
67
|
+
}): Promise<AdminCreditTransactionsResponse>;
|
|
68
|
+
fetchAdminAiGenerations(options?: {
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
}): Promise<AiGenerationsResponse>;
|
|
72
|
+
fetchAdminAiGeneration(id: string): Promise<AiGenerationDetailResponse>;
|
|
73
|
+
};
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/domains/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE;IAChC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC,KAAK,YAAY,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC;AAC1F,KAAK,iBAAiB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/D,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,YAAY,CAAC;IAC7B,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,gBAAgB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;kBAauB,OAAO,CAAC,iBAAiB,CAAC;4BAahB,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;sCAcrC,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC;2BA8BvD,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;4BAalC,MAAM,iBAAiB,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;4BAc1E,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;sBAa/C,OAAO,CAAC,qBAAqB,CAAC;uBAa7B,MAAM,iBAAiB,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;uBAc9E,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;6BAa7B,OAAO,CAAC,mBAAmB,CAAC;gCAWzB;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;+BAahI,MAAM,QACL;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAClE,OAAO,CAAC,kBAAkB,CAAC;+BAYG,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;kCAWnC,OAAO,CAAC,mBAAmB,CAAC;iCAW7B;QACjC,QAAQ,CAAC,EAAE,eAAe,CAAC;QAC3B,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,CAAC;QACzC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,yBAAyB,CAAC;iCAyCH,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;kCAW3C,MAAM,QAAQ,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;qCAY1E,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;2CAWtC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC;sCAoBnF;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;+BAoB3E,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;EAWhF"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
export function buildAdminApiClientMethods(input) {
|
|
2
|
+
const { request, handleApiError, fetchImpl, resolveBaseUrl, resolveUrl, parseResponseBody, resolveToken, getClientHeaders, } = input;
|
|
3
|
+
return {
|
|
4
|
+
async fetchUsers() {
|
|
5
|
+
const response = await request({
|
|
6
|
+
method: 'GET',
|
|
7
|
+
path: '/admin/users',
|
|
8
|
+
});
|
|
9
|
+
if (response.status !== 200) {
|
|
10
|
+
handleApiError(response, 'fetch_users');
|
|
11
|
+
}
|
|
12
|
+
return response.body;
|
|
13
|
+
},
|
|
14
|
+
async createUser(userRequest) {
|
|
15
|
+
const response = await request({
|
|
16
|
+
method: 'POST',
|
|
17
|
+
path: '/admin/users',
|
|
18
|
+
body: userRequest,
|
|
19
|
+
});
|
|
20
|
+
if (response.status !== 201 && response.status !== 200) {
|
|
21
|
+
handleApiError(response, 'create_user');
|
|
22
|
+
}
|
|
23
|
+
return response.body;
|
|
24
|
+
},
|
|
25
|
+
async batchCreateUsersFromCsv(formData) {
|
|
26
|
+
const base = resolveBaseUrl();
|
|
27
|
+
const headers = new Headers();
|
|
28
|
+
for (const [key, value] of Object.entries(getClientHeaders())) {
|
|
29
|
+
headers.set(key, value);
|
|
30
|
+
}
|
|
31
|
+
const token = await resolveToken();
|
|
32
|
+
if (token) {
|
|
33
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
34
|
+
}
|
|
35
|
+
const path = '/admin/users/batch-create';
|
|
36
|
+
const response = await fetchImpl(resolveUrl(base, path), {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers,
|
|
39
|
+
body: formData,
|
|
40
|
+
});
|
|
41
|
+
const parsed = await parseResponseBody(response);
|
|
42
|
+
const apiResponse = { status: response.status, body: parsed, headers: response.headers };
|
|
43
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
44
|
+
handleApiError(apiResponse, 'batch_create_users');
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
47
|
+
},
|
|
48
|
+
async fetchAdminUser(userId) {
|
|
49
|
+
const response = await request({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
path: `/admin/users/${encodeURIComponent(String(userId))}`,
|
|
52
|
+
});
|
|
53
|
+
if (response.status !== 200) {
|
|
54
|
+
handleApiError(response, 'fetch_admin_user');
|
|
55
|
+
}
|
|
56
|
+
return response.body;
|
|
57
|
+
},
|
|
58
|
+
async updateAdminUser(userId, updateRequest) {
|
|
59
|
+
const response = await request({
|
|
60
|
+
method: 'PATCH',
|
|
61
|
+
path: `/admin/users/${encodeURIComponent(String(userId))}`,
|
|
62
|
+
body: updateRequest,
|
|
63
|
+
});
|
|
64
|
+
if (response.status !== 200) {
|
|
65
|
+
handleApiError(response, 'update_admin_user');
|
|
66
|
+
}
|
|
67
|
+
return response.body;
|
|
68
|
+
},
|
|
69
|
+
async deleteAdminUser(userId) {
|
|
70
|
+
const response = await request({
|
|
71
|
+
method: 'DELETE',
|
|
72
|
+
path: `/admin/users/${encodeURIComponent(String(userId))}`,
|
|
73
|
+
});
|
|
74
|
+
if (response.status !== 200) {
|
|
75
|
+
handleApiError(response, 'delete_admin_user');
|
|
76
|
+
}
|
|
77
|
+
return response.body;
|
|
78
|
+
},
|
|
79
|
+
async fetchAdminApps() {
|
|
80
|
+
const response = await request({
|
|
81
|
+
method: 'GET',
|
|
82
|
+
path: '/admin/apps',
|
|
83
|
+
});
|
|
84
|
+
if (response.status !== 200) {
|
|
85
|
+
handleApiError(response, 'fetch_admin_apps');
|
|
86
|
+
}
|
|
87
|
+
return response.body;
|
|
88
|
+
},
|
|
89
|
+
async updateAdminApp(id, updateRequest) {
|
|
90
|
+
const response = await request({
|
|
91
|
+
method: 'PATCH',
|
|
92
|
+
path: `/admin/apps/${encodeURIComponent(String(id))}`,
|
|
93
|
+
body: updateRequest,
|
|
94
|
+
});
|
|
95
|
+
if (response.status !== 200) {
|
|
96
|
+
handleApiError(response, 'update_admin_app');
|
|
97
|
+
}
|
|
98
|
+
return response.body;
|
|
99
|
+
},
|
|
100
|
+
async deleteAdminApp(id) {
|
|
101
|
+
const response = await request({
|
|
102
|
+
method: 'DELETE',
|
|
103
|
+
path: `/admin/apps/${encodeURIComponent(String(id))}`,
|
|
104
|
+
});
|
|
105
|
+
if (response.status !== 200) {
|
|
106
|
+
handleApiError(response, 'delete_admin_app');
|
|
107
|
+
}
|
|
108
|
+
return response.body;
|
|
109
|
+
},
|
|
110
|
+
async fetchAdminCreditPacks() {
|
|
111
|
+
const response = await request({
|
|
112
|
+
method: 'GET',
|
|
113
|
+
path: '/admin/credit-packs',
|
|
114
|
+
});
|
|
115
|
+
if (response.status !== 200) {
|
|
116
|
+
handleApiError(response, 'fetch_admin_credit_packs');
|
|
117
|
+
}
|
|
118
|
+
return response.body;
|
|
119
|
+
},
|
|
120
|
+
async createAdminCreditPack(body) {
|
|
121
|
+
const response = await request({
|
|
122
|
+
method: 'POST',
|
|
123
|
+
path: '/admin/credit-packs',
|
|
124
|
+
body,
|
|
125
|
+
});
|
|
126
|
+
if (response.status !== 201) {
|
|
127
|
+
handleApiError(response, 'create_admin_credit_pack');
|
|
128
|
+
}
|
|
129
|
+
return response.body;
|
|
130
|
+
},
|
|
131
|
+
async updateAdminCreditPack(sku, body) {
|
|
132
|
+
const response = await request({
|
|
133
|
+
method: 'PATCH',
|
|
134
|
+
path: `/admin/credit-packs/${encodeURIComponent(sku)}`,
|
|
135
|
+
body,
|
|
136
|
+
});
|
|
137
|
+
if (response.status !== 200) {
|
|
138
|
+
handleApiError(response, 'update_admin_credit_pack');
|
|
139
|
+
}
|
|
140
|
+
return response.body;
|
|
141
|
+
},
|
|
142
|
+
async deleteAdminCreditPack(sku) {
|
|
143
|
+
const response = await request({
|
|
144
|
+
method: 'DELETE',
|
|
145
|
+
path: `/admin/credit-packs/${encodeURIComponent(sku)}`,
|
|
146
|
+
});
|
|
147
|
+
if (response.status !== 200) {
|
|
148
|
+
handleApiError(response, 'delete_admin_credit_pack');
|
|
149
|
+
}
|
|
150
|
+
return response.body;
|
|
151
|
+
},
|
|
152
|
+
async syncAdminCreditPacksStripe() {
|
|
153
|
+
const response = await request({
|
|
154
|
+
method: 'POST',
|
|
155
|
+
path: '/admin/credit-packs/sync-stripe',
|
|
156
|
+
});
|
|
157
|
+
if (response.status !== 200) {
|
|
158
|
+
handleApiError(response, 'sync_admin_credit_packs_stripe');
|
|
159
|
+
}
|
|
160
|
+
return response.body;
|
|
161
|
+
},
|
|
162
|
+
async fetchAdminPayments(options) {
|
|
163
|
+
const params = new URLSearchParams();
|
|
164
|
+
if (options?.provider) {
|
|
165
|
+
params.set('provider', options.provider);
|
|
166
|
+
}
|
|
167
|
+
if (options?.status) {
|
|
168
|
+
const statuses = Array.isArray(options.status) ? options.status : [options.status];
|
|
169
|
+
params.set('status', statuses.join(','));
|
|
170
|
+
}
|
|
171
|
+
if (typeof options?.userId === 'number') {
|
|
172
|
+
params.set('userId', String(options.userId));
|
|
173
|
+
}
|
|
174
|
+
if (options?.creditPackSku) {
|
|
175
|
+
params.set('creditPackSku', options.creditPackSku);
|
|
176
|
+
}
|
|
177
|
+
if (options?.from) {
|
|
178
|
+
const fromValue = options.from instanceof Date ? options.from.toISOString() : options.from;
|
|
179
|
+
params.set('from', fromValue);
|
|
180
|
+
}
|
|
181
|
+
if (options?.to) {
|
|
182
|
+
const toValue = options.to instanceof Date ? options.to.toISOString() : options.to;
|
|
183
|
+
params.set('to', toValue);
|
|
184
|
+
}
|
|
185
|
+
if (typeof options?.limit === 'number') {
|
|
186
|
+
params.set('limit', String(options.limit));
|
|
187
|
+
}
|
|
188
|
+
if (typeof options?.offset === 'number') {
|
|
189
|
+
params.set('offset', String(options.offset));
|
|
190
|
+
}
|
|
191
|
+
const query = params.toString();
|
|
192
|
+
const path = query ? `/admin/payments?${query}` : '/admin/payments';
|
|
193
|
+
const response = await request({
|
|
194
|
+
method: 'GET',
|
|
195
|
+
path,
|
|
196
|
+
});
|
|
197
|
+
if (response.status !== 200) {
|
|
198
|
+
handleApiError(response, 'fetch_admin_payments');
|
|
199
|
+
}
|
|
200
|
+
return response.body;
|
|
201
|
+
},
|
|
202
|
+
async fetchAdminPayment(paymentId) {
|
|
203
|
+
const response = await request({
|
|
204
|
+
method: 'GET',
|
|
205
|
+
path: `/admin/payments/${encodeURIComponent(String(paymentId))}`,
|
|
206
|
+
});
|
|
207
|
+
if (response.status !== 200) {
|
|
208
|
+
handleApiError(response, 'fetch_admin_payment');
|
|
209
|
+
}
|
|
210
|
+
return response.body;
|
|
211
|
+
},
|
|
212
|
+
async refundAdminPayment(paymentId, body) {
|
|
213
|
+
const response = await request({
|
|
214
|
+
method: 'POST',
|
|
215
|
+
path: `/admin/payments/${encodeURIComponent(String(paymentId))}/refund`,
|
|
216
|
+
body,
|
|
217
|
+
});
|
|
218
|
+
if (response.status !== 200) {
|
|
219
|
+
handleApiError(response, 'refund_admin_payment');
|
|
220
|
+
}
|
|
221
|
+
return response.body;
|
|
222
|
+
},
|
|
223
|
+
async reconcileAdminPayment(paymentId) {
|
|
224
|
+
const response = await request({
|
|
225
|
+
method: 'POST',
|
|
226
|
+
path: `/admin/payments/${encodeURIComponent(String(paymentId))}/reconcile`,
|
|
227
|
+
});
|
|
228
|
+
if (response.status !== 200) {
|
|
229
|
+
handleApiError(response, 'reconcile_admin_payment');
|
|
230
|
+
}
|
|
231
|
+
return response.body;
|
|
232
|
+
},
|
|
233
|
+
async fetchAdminCreditTransactions(options) {
|
|
234
|
+
const params = new URLSearchParams();
|
|
235
|
+
if (options?.limit !== undefined) {
|
|
236
|
+
params.set('limit', String(options.limit));
|
|
237
|
+
}
|
|
238
|
+
if (options?.offset !== undefined) {
|
|
239
|
+
params.set('offset', String(options.offset));
|
|
240
|
+
}
|
|
241
|
+
const query = params.toString();
|
|
242
|
+
const path = query ? `/admin/credit-transactions?${query}` : '/admin/credit-transactions';
|
|
243
|
+
const response = await request({
|
|
244
|
+
method: 'GET',
|
|
245
|
+
path,
|
|
246
|
+
});
|
|
247
|
+
if (response.status !== 200) {
|
|
248
|
+
handleApiError(response, 'fetch_admin_credit_transactions');
|
|
249
|
+
}
|
|
250
|
+
return response.body;
|
|
251
|
+
},
|
|
252
|
+
async fetchAdminAiGenerations(options) {
|
|
253
|
+
const params = new URLSearchParams();
|
|
254
|
+
if (options?.limit !== undefined) {
|
|
255
|
+
params.set('limit', String(options.limit));
|
|
256
|
+
}
|
|
257
|
+
if (options?.offset !== undefined) {
|
|
258
|
+
params.set('offset', String(options.offset));
|
|
259
|
+
}
|
|
260
|
+
const query = params.toString();
|
|
261
|
+
const path = query ? `/admin/ai-generations?${query}` : '/admin/ai-generations';
|
|
262
|
+
const response = await request({
|
|
263
|
+
method: 'GET',
|
|
264
|
+
path,
|
|
265
|
+
});
|
|
266
|
+
if (response.status !== 200) {
|
|
267
|
+
handleApiError(response, 'fetch_admin_ai_generations');
|
|
268
|
+
}
|
|
269
|
+
return response.body;
|
|
270
|
+
},
|
|
271
|
+
async fetchAdminAiGeneration(id) {
|
|
272
|
+
const response = await request({
|
|
273
|
+
method: 'GET',
|
|
274
|
+
path: `/admin/ai-generations/${id}`,
|
|
275
|
+
});
|
|
276
|
+
if (response.status !== 200) {
|
|
277
|
+
handleApiError(response, 'fetch_admin_ai_generation');
|
|
278
|
+
}
|
|
279
|
+
return response.body;
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AiGenerationDetailResponse } from '@playdrop/types';
|
|
2
|
+
type ApiResponseLike<T> = {
|
|
3
|
+
status: number;
|
|
4
|
+
body: T;
|
|
5
|
+
headers: Headers;
|
|
6
|
+
};
|
|
7
|
+
type RequestExecutor = <T>(input: {
|
|
8
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
9
|
+
path: string;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}) => Promise<ApiResponseLike<T>>;
|
|
14
|
+
type ErrorHandler = (response: ApiResponseLike<unknown>, defaultMessage: string) => never;
|
|
15
|
+
export declare function buildAiApiClientMethods(input: {
|
|
16
|
+
request: RequestExecutor;
|
|
17
|
+
handleApiError: ErrorHandler;
|
|
18
|
+
}): {
|
|
19
|
+
fetchAiGeneration(id: string): Promise<AiGenerationDetailResponse>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/domains/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAElE,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE;IAChC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC,KAAK,YAAY,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC;AAE1F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,YAAY,CAAC;CAC9B;0BAI+B,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;EAW3E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function buildAiApiClientMethods(input) {
|
|
2
|
+
const { request, handleApiError } = input;
|
|
3
|
+
return {
|
|
4
|
+
async fetchAiGeneration(id) {
|
|
5
|
+
const response = await request({
|
|
6
|
+
method: 'GET',
|
|
7
|
+
path: `/ai-generations/${encodeURIComponent(id)}`,
|
|
8
|
+
});
|
|
9
|
+
if (response.status !== 200) {
|
|
10
|
+
handleApiError(response, 'fetch_ai_generation');
|
|
11
|
+
}
|
|
12
|
+
return response.body;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|