diff --git a/.claude/skills/pest-testing/SKILL.md b/.claude/skills/pest-testing/SKILL.md index 323d4723..f748676d 100644 --- a/.claude/skills/pest-testing/SKILL.md +++ b/.claude/skills/pest-testing/SKILL.md @@ -18,6 +18,12 @@ ### Creating Tests All tests must be written using Pest. Use `php artisan make:test --pest {name}`. +The `{name}` argument should include only the path and test name, but should not include the test suite. +- Incorrect: `php artisan make:test --pest Feature/SomeFeatureTest` will generate `tests/Feature/Feature/SomeFeatureTest.php` +- Correct: `php artisan make:test --pest SomeControllerTest` will generate `tests/Feature/SomeControllerTest.php` +- Incorrect: `php artisan make:test --pest --unit Unit/SomeServiceTest` will generate `tests/Unit/Unit/SomeServiceTest.php` +- Correct: `php artisan make:test --pest --unit SomeServiceTest` will generate `tests/Unit/SomeServiceTest.php` + ### Test Organization - Unit/Feature tests: `tests/Feature` and `tests/Unit` directories. @@ -156,4 +162,5 @@ ## Common Pitfalls - Using `assertStatus(200)` instead of `assertSuccessful()` - Forgetting datasets for repetitive validation tests - Deleting tests without approval -- Forgetting `assertNoJavaScriptErrors()` in browser tests \ No newline at end of file +- Forgetting `assertNoJavaScriptErrors()` in browser tests +- Prefixing `Feature/` or `Unit/` in `{name}` when using `make:test` \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e0311201..8d4d5341 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -89,6 +89,9 @@ jobs: DB_PORT: ${{ job.services.postgres.ports['5432'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }} + - name: Generate Passport keys + run: php artisan passport:keys --force + - name: Run tests run: php artisan test --compact env: diff --git a/CLAUDE.md b/CLAUDE.md index 7389a0db..4764be1f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,21 +41,7 @@ ## Foundational Context ## Skills Activation -This project has domain-specific skills available. You MUST activate the relevant skill whenever you work in that domain—don't wait until you're stuck. - -- `ai-sdk-development` — TRIGGER when working with ai-sdk which is Laravel official first-party AI SDK. Activate when building, editing AI agents, chatbots, text generation, image generation, audio/TTS, transcription/STT, embeddings, RAG, vector stores, reranking, structured output, streaming, conversation memory, tools, queueing, broadcasting, and provider failover across OpenAI, Anthropic, Gemini, Azure, Groq, xAI, DeepSeek, Mistral, Ollama, ElevenLabs, Cohere, Jina, and VoyageAI. Invoke when the user references ai-sdk, the `Laravel\Ai\` namespace, or this project's AI features — not for Prism PHP or other AI packages used directly. -- `cashier-stripe-development` — Handles Laravel Cashier Stripe integration including subscriptions, webhooks, Stripe Checkout, invoices, charges, refunds, trials, coupons, metered billing, and payment failure handling. Triggered when a user mentions Cashier, Billable, IncompletePayment, stripe_id, newSubscription, Stripe subscriptions, or billing. Also applies when setting up webhooks, handling SCA/3DS payment failures, testing with Stripe test cards, or troubleshooting incomplete subscriptions, CSRF webhook errors, or migration publish issues. -- `laravel-best-practices` — Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns. -- `configuring-horizon` — Use this skill whenever the user mentions Horizon by name in a Laravel context. Covers the full Horizon lifecycle: installing Horizon (horizon:install, Sail setup), configuring config/horizon.php (supervisor blocks, queue assignments, balancing strategies, minProcesses/maxProcesses), fixing the dashboard (authorization via Gate::define viewHorizon, blank metrics, horizon:snapshot scheduling), and troubleshooting production issues (worker crashes, timeout chain ordering, LongWaitDetected notifications, waits config). Also covers job tagging and silencing. Do not use for generic Laravel queues without Horizon, SQS or database drivers, standalone Redis setup, Linux supervisord, Telescope, or job batching. -- `mcp-development` — Use this skill for Laravel MCP development only. Trigger when creating or editing MCP tools, resources, prompts, or servers in Laravel projects. Covers: artisan make:mcp-* generators, mcp:inspector, routes/ai.php, Tool/Resource/Prompt classes, schema validation, shouldRegister(), OAuth setup, URI templates, read-only attributes, and MCP debugging. Do not use for non-Laravel MCP projects or generic AI features without MCP. -- `configure-nightwatch` — Configures Laravel Nightwatch data collection, sampling rates, filtering rules, and redaction policies. Use when setting up Nightwatch, managing data volume, protecting sensitive data (PII), or optimizing event collection for production workloads. -- `passport-development` — Develops OAuth2 API authentication with Laravel Passport. Activates when installing or configuring Passport; setting up OAuth2 grants (authorization code, client credentials, personal access tokens, device authorization); managing OAuth clients; protecting API routes with token authentication; defining or checking token scopes; configuring SPA cookie authentication; handling token lifetimes and refresh tokens; or when the user mentions Passport, OAuth2, API tokens, bearer tokens, or API authentication. Make sure to use this skill whenever the user works with OAuth2, API tokens, or third-party API access, even if they don't explicitly mention Passport. -- `pennant-development` — Use when working with Laravel Pennant the official Laravel feature flag package. Trigger whenever the query mentions Pennant by name or involves feature flags or feature toggles in a Laravel project. Tasks include defining feature flags checking whether features are active creating class based features in `app/Features` using Blade `@feature` directives scoping flags to users or teams building custom Pennant storage drivers protecting routes with feature flags testing feature flags with Pest or PHPUnit and implementing A B testing or gradual rollouts with feature flags. Do not trigger for generic Laravel configuration authorization policies authentication or non Pennant feature management systems. -- `socialite-development` — Manages OAuth social authentication with Laravel Socialite. Activate when adding social login providers; configuring OAuth redirect/callback flows; retrieving authenticated user details; customizing scopes or parameters; setting up community providers; testing with Socialite fakes; or when the user mentions social login, OAuth, Socialite, or third-party authentication. -- `wayfinder-development` — Use this skill for Laravel Wayfinder which auto-generates typed functions for Laravel controllers and routes. ALWAYS use this skill when frontend code needs to call backend routes or controller actions. Trigger when: connecting any React/Vue/Svelte/Inertia frontend to Laravel controllers, routes, building end-to-end features with both frontend and backend, wiring up forms or links to backend endpoints, fixing route-related TypeScript errors, importing from @/actions or @/routes, or running wayfinder:generate. Use Wayfinder route functions instead of hardcoded URLs. Covers: wayfinder() vite plugin, .url()/.get()/.post()/.form(), query params, route model binding, tree-shaking. Do not use for backend-only task -- `pest-testing` — Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to write something in Pest, mentions test files or directories (tests/Feature, tests/Unit, tests/Browser), or needs browser testing, smoke testing multiple pages for JS errors, or architecture tests. Covers: test()/it()/expect() syntax, datasets, mocking, browser testing (visit/click/fill), smoke testing, arch(), Livewire component tests, RefreshDatabase, and all Pest 4 features. Do not use for factories, seeders, migrations, controllers, models, or non-test PHP code. -- `inertia-vue-development` — Develops Inertia.js v3 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using ,
, useForm, useHttp, setLayoutProps, or router; working with deferred props, prefetching, optimistic updates, instant visits, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation. -- `tailwindcss-development` — Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3/v4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML/CSS component, CSS file audits, build tool configuration, and vanilla CSS. +This project has domain-specific skills available in `**/skills/**`. You MUST activate the relevant skill whenever you work in that domain—don't wait until you're stuck. ## Conventions @@ -130,10 +116,16 @@ # PHP - Always use curly braces for control structures, even for single-line bodies. - Use PHP 8 constructor property promotion: `public function __construct(public GitHub $github) { }`. Do not leave empty zero-parameter `__construct()` methods unless the constructor is private. - Use explicit return type declarations and type hints for all method parameters: `function isAccessible(User $user, ?string $path = null): bool` -- Follow existing application Enum naming conventions. +- Use TitleCase for Enum keys: `FavoritePerson`, `BestLake`, `Monthly`. - Prefer PHPDoc blocks over inline comments. Only add inline comments for exceptionally complex logic. - Use array shape type definitions in PHPDoc blocks. +=== deployments rules === + +# Deployment + +- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications. + === herd rules === # Laravel Herd @@ -201,10 +193,6 @@ ## Vite Error - If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`. -## Deployment - -- Laravel can be deployed using [Laravel Cloud](https://cloud.laravel.com/), which is the fastest way to deploy and scale production Laravel applications. - === wayfinder/core rules === # Laravel Wayfinder @@ -223,6 +211,7 @@ # Laravel Pint Code Formatter ## Pest - This project uses Pest for testing. Create tests: `php artisan make:test --pest {name}`. +- The `{name}` argument should not include the test suite directory. Use `php artisan make:test --pest SomeFeatureTest` instead of `php artisan make:test --pest Feature/SomeFeatureTest`. - Run tests: `php artisan test --compact` or filter: `php artisan test --compact --filter=testName`. - Do NOT delete tests without approval. diff --git a/LICENSE.md b/LICENSE.md index e6f59496..0c97efd2 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,65 +1,235 @@ -# TryPost License +GNU AFFERO GENERAL PUBLIC LICENSE +Version 3, 19 November 2007 -## Functional Source License, Version 1.1, MIT +Copyright (C) 2007 Free Software Foundation, Inc. -### Licensor +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -TryPost + Preamble -### Software +The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. -TryPost - Social Media Scheduling Platform +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. -### Use Limitation +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. -You may not use the Software to provide a commercial service that allows third parties to schedule, manage, or publish content to social media platforms, where such service competes with or substitutes for TryPost or any product or service provided by Licensor. +Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. -### License Grant +A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. -Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Software. If your use of the Software does not violate the Use Limitation, Licensor hereby grants you the right to make production use of the Software. +The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. -### Permitted Uses +An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. -The following uses are expressly permitted: +The precise terms and conditions for copying, distribution and modification follow. -1. **Personal Use**: Using TryPost for your own personal social media management -2. **Internal Business Use**: Using TryPost within your organization to manage your company's social media accounts -3. **Educational Use**: Using TryPost for learning, teaching, or research purposes -4. **Development**: Modifying, studying, or contributing to the TryPost codebase -5. **Self-Hosting**: Deploying TryPost on your own infrastructure for personal or internal business use + TERMS AND CONDITIONS -### Prohibited Uses +0. Definitions. -The following uses are expressly prohibited: +"This License" refers to version 3 of the GNU Affero General Public License. -1. **Competing SaaS**: Offering TryPost (or a modified version) as a hosted service to third parties -2. **White-Label Services**: Rebranding and selling TryPost as your own product -3. **Managed Service Provider**: Operating TryPost as a service for multiple clients or customers +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. -### Corollary +"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. -For clarity, the Use Limitation does not prohibit: +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. -- Using TryPost to manage social media for your own business or clients (as a social media manager) -- Integrating TryPost into internal tools that are not offered as a competing service -- Contributing improvements back to the TryPost project +A "covered work" means either the unmodified Program or a work based on the Program. -### Notice +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. -You must ensure that anyone who receives a copy of any part of the Software from you also receives a copy of this License. +To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. -### No Other Rights +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. -These terms do not grant you any right in any trademark or logo of Licensor or its affiliates. +1. Source Code. +The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. -### Patent +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. -To the extent your use qualifies as a Permitted Use, Licensor grants you a license under any patent claims it can license that are necessarily infringed by the Software, to make, use, and distribute the Software. +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. -### Disclaimer +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those +subprograms and other parts of the work. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. ---- +The Corresponding Source for a work in source code form is that same work. -Copyright (c) 2025 TryPost +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . diff --git a/README.md b/README.md index ae9335a5..3e96fdeb 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,23 @@

- The open-source social media scheduling platform + The open-source alternative to Buffer, Hootsuite, and Later.

- Schedule, manage, and publish content to all your social media accounts from one place. -
- Self-hosted. Privacy-focused. No limits. + Schedule, write, and publish to every social network from one place.
+ Self-hosted. Built for teams, agencies, and creators who own their data.

- Stars - License - Release + Stars + License + Release + Discussions

+ Cloud • Documentation • Roadmap • Community @@ -26,31 +27,50 @@ --- -## Why TryPost? +## TryPost 1.0 is here -Tired of paying expensive monthly fees for social media scheduling tools? Want full control over your data? TryPost is the solution. +A massive release that turns TryPost into a complete open-source social media platform. -| | | -| ----------------------- | ---------------------------------------------------- | -| **100% Open Source** | Inspect the code, contribute, make it yours | -| **Self-Hosted** | Your data stays on your servers | -| **No Limits** | Schedule unlimited posts, connect unlimited accounts | -| **Privacy First** | No tracking, no analytics, no data selling | +- **MCP Server** — connect Claude, Cursor, ChatGPT, and any MCP client. Schedule, publish, and pull metrics with natural language. +- **REST API** — Personal Access Tokens, every workflow you can do in the dashboard, available over HTTP. +- **Workspaces & Teams** — manage multiple brands or clients in isolated environments. Invite team members with role-based permissions. +- **AI Carousel Generator** — type a prompt, get a multi-slide LinkedIn / Instagram carousel back, with images and copy on-brand. +- **Brand Profile** — set tone, voice, language, and colors once. Every AI generation respects them automatically. +- **Analytics** — per-account engagement metrics from every platform that exposes them, in a single dashboard. + +Read the [release notes →](https://github.com/trypost-it/trypost/releases/latest) + +--- + +## Why TryPost + +Tired of paying $30–$200/month per user for a scheduler? Tired of your content sitting on someone else's database? + +| | | +| ---------------------------- | ---------------------------------------------------------- | +| **Self-hosted, your data** | Your posts, drafts, and metrics never leave your server | +| **No artificial limits** | Unlimited posts, unlimited connected accounts, unlimited workspaces | +| **AI built in** | Captions, carousels, on-brand voice — using your own keys | +| **Multi-tenant ready** | Workspaces + roles for agencies managing many clients | +| **API + MCP first-class** | Automate everything; your AI assistant can post for you | +| **AGPL-licensed** | Inspect every line, fork it, ship it — forever free | ## Features -| | | -| ----------------------------- | ------------------------------------------------------- | -| **Visual Calendar** | Drag and drop posts across your content calendar | -| **Post Composer** | Create and preview posts for multiple platforms at once | -| **Media Library** | Upload images and videos with automatic optimization | -| **Team Collaboration** | Invite team members with role-based permissions (Owner, Admin, Member) | -| **Workspaces** | Manage multiple brands or clients separately | -| **REST API** | Full API with Bearer token authentication | -| **MCP Server** | AI-ready with Model Context Protocol support | -| **Google Login** | Sign up and log in with Google OAuth | -| **Notifications** | In-app and email notifications for post status | -| **i18n** | Available in English, Spanish, and Portuguese | +| | | +| ------------------------------ | ---------------------------------------------------------------------- | +| **Visual Calendar** | See every scheduled post at a glance, switch between month/week/day | +| **Multi-Platform Composer** | One draft → preview & tweak for every network in parallel | +| **AI Generate / Review** | Draft from a prompt, get inline feedback before you publish | +| **AI Carousel Builder** | Prompt → multi-slide carousel with images, on-brand | +| **Brand Profile** | Tone, voice, language, colors — applied to every AI call | +| **Asset Library** | Reusable workspace media + Unsplash & Giphy search built in | +| **Signatures & Labels** | Reusable text blocks (hashtags, CTAs) and color-coded post tags | +| **Team Collaboration** | Owner / Admin / Member roles, comments with @mentions on drafts | +| **Workspaces** | Isolate brands, clients, or projects in their own spaces | +| **REST API + MCP** | Full programmatic control; AI assistants integrate natively | +| **Analytics** | Per-account engagement metrics across every supported platform | +| **Multi-language** | English, Spanish, Portuguese | ## Supported Platforms @@ -71,75 +91,26 @@ ## Supported Platforms -## Tech Stack - -| Layer | Technology | -| ----- | ---------- | -| **Backend** | Laravel 13, PHP 8.4 | -| **Frontend** | Vue 3, Inertia.js v3, Tailwind CSS v4 | -| **Database** | PostgreSQL | -| **Queue** | Redis + Laravel Horizon | -| **WebSockets** | Laravel Reverb | -| **API** | REST with Bearer token auth | -| **MCP** | Laravel MCP for AI integrations | -| **Payments** | Laravel Cashier (Stripe) | - -## Getting Started - -Get TryPost running in minutes: +## Get Started | | | | --- | --- | -| [Installation Guide](https://trypost.it/docs/getting-started/installation) | Step-by-step setup | -| [Docker Setup](https://trypost.it/docs/self-hosting/docker) | Run with Laravel Sail | -| [Configuration](https://trypost.it/docs/getting-started/configuration) | Environment setup | -| [Platform Setup](https://trypost.it/docs/platforms/) | Connect your social accounts | - -### Quick Start - -```bash -git clone https://github.com/trypost-it/trypost.git -cd trypost -cp .env.example .env -composer install -npm install -php artisan key:generate -php artisan migrate -npm run build -``` - -## API - -TryPost includes a REST API for programmatic access. All endpoints are under `/api` and require a Bearer token. - -```bash -curl -H "Authorization: Bearer tp_your_token" \ - https://your-domain.com/api/posts -``` - -See the [API documentation](https://trypost.it/docs/api) for all available endpoints. - -## MCP Server - -TryPost ships with a Model Context Protocol (MCP) server at `/mcp/trypost`, enabling AI assistants to manage your social media directly. +| **Try it on Cloud** | The fastest way. [Sign up at trypost.it](https://trypost.it) | +| **Self-host** | Free forever. [Installation guide →](https://trypost.it/docs/getting-started/installation) | +| **Run with AI assistants** | [Connect Claude / Cursor / ChatGPT via MCP →](https://trypost.it/docs/mcp) | ## Contributing -We love contributions! Check the [issues](https://github.com/trypost-it/trypost/issues) for open tasks. +We love contributions, no matter how small. Pick an [issue](https://github.com/trypost-it/trypost/issues), say hi in [Discussions](https://github.com/trypost-it/trypost/discussions), or just open a PR with what you'd like to see. -- [Discussions](https://github.com/trypost-it/trypost/discussions) - Ask questions, share ideas -- [Issues](https://github.com/trypost-it/trypost/issues) - Report bugs, request features +If TryPost is useful to you, **a star helps more people find it.** That's the most valuable contribution if you're short on time. ## License -TryPost is licensed under the [Functional Source License (FSL)](LICENSE.md). - -**You can:** Use for personal or business use, self-host, modify and contribute. - -**You cannot:** Offer as a competing SaaS, white-label and resell. +[GNU Affero General Public License v3.0](LICENSE.md) — use, modify, fork, self-host, and redistribute, including commercially. If you run a modified version as a network service, you need to make your changes available to its users (AGPL §13). ---

- If TryPost helps you, please give us a star + Built openly by the community. Star us on GitHub and tell a friend.

diff --git a/TIKTOK_REVIEW_VIDEO_SCRIPT.md b/TIKTOK_REVIEW_VIDEO_SCRIPT.md deleted file mode 100644 index cd781fcc..00000000 --- a/TIKTOK_REVIEW_VIDEO_SCRIPT.md +++ /dev/null @@ -1,333 +0,0 @@ -# TikTok Direct Post API — Review Video Script - -Script for re-submitting trypost to TikTok's Direct Post API audit after the initial rejection. Based on https://developers.tiktok.com/doc/content-sharing-guidelines/ - -Goal: in ~2–3 minutes of screen recording, prove **every** compliance requirement visually. Narration in English (reviewers are in English-speaking teams). - ---- - -## 0. Pre-recording checklist - -Before hitting record, set up the state so you can flow through the script without pauses. - -### Account / environment -- [ ] A **real TikTok account** connected to trypost (use your personal, not a test stub) -- [ ] Post log in production (`app.trypost.it`) — **not** localhost. Reviewers distrust `.test` domains -- [ ] `npm run build` deployed. Browser cache cleared (hard reload) -- [ ] Dev Tools closed, clean Chrome profile (no extensions bar visible) - -### Content to upload -- [ ] One short vertical video (15–30s, 720p+) — original content. **Not** reposted from another platform -- [ ] A caption draft written (avoid preset auto-text — reviewer must see it's editable) -- [ ] Optional: a long video (>max duration of your account) to demonstrate the duration warning - -### Workspace state -- [ ] Have a **second TikTok account** also connected — the video should demonstrate multi-account support (each collapse is per-account) -- [ ] Confirm `creator_info` is actually loading (watch Network tab once before recording) - -### Recording tool -- Mac: QuickTime > File > New Screen Recording (record cursor + microphone) -- Resolution: 1440p minimum, browser window at 80% scale -- Narration: headset mic, quiet room - ---- - -## 1. Opening shot (0:00–0:10) - -**Screen:** trypost dashboard home (`/calendar` or `/posts`). - -**Narration:** -> "Hi TikTok team. I'm demonstrating the trypost Direct Post integration. trypost is a social media scheduler for authentic creators. Let me walk you through the posting flow for TikTok." - -**Why:** establishes you're not copying from another platform and the app is a scheduler for original content (addresses "Intended Use Requirements" in the doc). - ---- - -## 2. TikTok authorization flow (0:10–0:30) - -**Required by the submission form: "User flow of TikTok authorization page".** - -**Screen:** navigate to `/accounts` with no TikTok account connected yet. - -**Action:** -1. Click "Connect TikTok" button -2. Wait for TikTok's consent screen to load -3. Show the scopes list on TikTok's page -4. Click "Authorize" -5. Return to trypost with the account now connected (avatar + @handle visible) - -**Narration:** -> "To use trypost with TikTok, the creator first authorizes our app. Clicking Connect TikTok takes me to TikTok's official consent page, where I can see the exact scopes we request: user profile, basic info, stats, and video publishing permissions. Once I authorize, I'm returned to trypost and my TikTok account is connected." - -**What MUST be visible:** -- trypost's Connect TikTok button -- TikTok's native authorization page (not a clone — the real `open-api.tiktok.com/platform/oauth/connect/` screen) -- The scope list on TikTok's page -- Return redirect back to trypost with the account populated - -## 3. Open post editor — creator_info fetched (0:30–0:45) - -**Screen:** click "Create post" or open an existing draft. - -**Action:** just wait 1–2s for the editor to render. - -**Narration:** -> "Now I'll open the post editor. When it loads, trypost automatically fetches the latest creator_info for my TikTok account, so all visibility options and interaction settings you'll see reflect my current account state." - -**What MUST be visible:** -- The post editor with the TikTok account nickname visible -- Optional: DevTools Network tab briefly showing the `post/publish/creator_info/query/` call - ---- - -## 3. Compose + media upload (0:25–0:40) - -**Screen:** post composer. - -**Action:** -1. Type a caption manually (e.g. "Testing the TikTok Direct Post integration") -2. Upload the video - -**Narration:** -> "I'll write my caption here — notice the caption field is fully editable; trypost does not inject any preset text or hashtags. Now I'll add my video, which I recorded myself." - -**What MUST be visible:** -- Caption is user-typed (no auto-fill) -- Media upload visible -- No watermarks or promotional logos added anywhere by trypost - ---- - -## 4. Open the Schedule tab + show creator nickname (0:40–0:55) - -**Screen:** right sidebar, click "Schedule" tab. - -**Action:** click on the TikTok platform in "Publish to" to select it. - -**Narration:** -> "I'll select my TikTok account to publish to. Notice the creator's nickname is displayed here so I know exactly which TikTok account this will post to." - -**What MUST be visible:** -- The TikTok platform card with **avatar + nickname visible** (not hidden in tooltip) -- Account visibly selected (primary ring) - ---- - -## 5. Expand TikTok Settings — walk through each compliance field (0:55–1:45) - -**Screen:** click to expand "TikTok Settings" collapse. - -**Narration (go slowly here — this is the compliance core):** - -### 5.1 Creator identity -> "Inside the settings, I see again which account I'm posting to: my nickname and handle." - -### 5.2 Privacy level -**Action:** click the "Who can see this video?" dropdown — reveal it's empty with "Select visibility" placeholder. - -> "Privacy is required — there is no default value. The user must explicitly choose a visibility. The options listed come directly from TikTok's creator_info API response, so only the visibility levels that my account can actually use are shown." - -**Key moment:** hover the dropdown open so the reviewer sees the options list. - -### 5.3 Interaction checkboxes -> "Next, the interaction settings — Comments, Duet, and Stitch. None of them are checked by default; I opt in to each." - -**Key moment:** if any of them are greyed out on your account (because you disabled them in TikTok app settings), hover over one and show the tooltip *"Disabled by your TikTok account settings"*. - -> "If any of these are disabled on my TikTok account itself, trypost respects that — the checkbox is greyed out and I cannot enable it." - -### 5.4 Video made with AI -> "There's an independent toggle to declare if the video was made with AI — off by default." - -### 5.5 Disclose video content toggle (CRITICAL SECTION) -**Action:** click the "Disclose video content" checkbox. - -> "This is the commercial content disclosure toggle. It starts OFF by default, as required. I'll turn it on to demonstrate." - -**What happens when ON:** sub-toggles "Your brand" and "Branded content" appear; a reminder text says *"You need to indicate if your content promotes yourself, a third party, or both"*. - -**Action:** scroll up to the top of the page — point at the **disabled** Schedule/Post now button. - -> "Right now, with the disclosure toggle on but no sub-option selected, the publish button is disabled, matching TikTok's requirement." - -**Action:** back to the settings, click "Your brand" sub-toggle. - -> "If I select Your brand, TikTok will classify this as Brand Organic. The disclosure reads: 'Your photo or video will be labeled as Promotional content'. Notice the agreement text below: 'By posting, you agree to TikTok's Music Usage Confirmation'." - -**Action:** un-select "Your brand", click "Branded content" instead. - -> "If I switch to Branded content, the label changes to 'Paid partnership', and the agreement now includes TikTok's Branded Content Policy, as required." - -**Action:** open the privacy dropdown again. - -> "And because branded content cannot be posted privately, the 'Only me' option is no longer available. If I had already picked 'Only me' before, trypost automatically clears the selection to force me to pick a valid one." - -### 5.6 Duration warning (skip if not applicable) -If you set up the long-video scenario: show the red warning *"Video is Xs long but this account can only post videos up to Ys"*. - ---- - -## 6. Preview tab (1:45–2:00) - -**Screen:** click the "Preview" tab. - -**Narration:** -> "Before posting, I can preview exactly how my post will look. This is the explicit consent step — I only publish after reviewing the content here." - -**What MUST be visible:** -- The preview shows the actual video + caption -- Clear that this happens before the upload - ---- - -## 7. Publish + processing notification (2:00–2:20) - -**Screen:** back to the composer / schedule view. - -**Action:** -1. Select a valid privacy level (e.g. Public) -2. Make sure disclose is OFF or one sub-toggle is picked -3. Click "Post now" - -**Narration:** -> "I'll set privacy to public and publish. After I hit post, trypost shows me a notification saying the content may take a few minutes to process and appear on my TikTok profile — exactly what TikTok's guideline specifies." - -**What MUST be visible:** -- Flash banner: *"Post is being published! It may take a few minutes to process and appear on each platform."* -- Button disables / spinner while submitting - ---- - -## 8. Verify on TikTok (2:20–2:40) - -**Action:** open tiktok.com in a new tab, navigate to your profile. - -**Narration:** -> "And here's the post on my TikTok profile, with the correct visibility, the interaction settings I chose, and — because I had Branded Content disclosed — the 'Paid partnership' label is applied by TikTok automatically." - -**What MUST be visible:** -- The exact video just uploaded, live on the TikTok profile -- If branded content was enabled: the "Paid partnership" label - ---- - -## 9. Bonus (optional, strong signal): multi-account support (2:40–3:00) - -**Screen:** go back to the post editor (or create a new post). - -**Action:** select a **second** TikTok account. Show that a second, independent "TikTok Settings" collapse appears for that account. - -**Narration:** -> "trypost supports posting to multiple TikTok accounts simultaneously. Each selected account gets its own settings panel with its own creator_info — so each account's privacy options and interaction rules are respected independently." - -**Why this helps:** shows you understand the per-creator nature of the compliance, which matches "creator-specific restrictions" in the doc. - ---- - -## 10. Closing (3:00 end) - -**Narration:** -> "That's the trypost Direct Post flow — fully aligned with TikTok's Content Sharing Guidelines. Thanks for reviewing." - -**Screen:** end on the TikTok profile showing the freshly-posted video. - ---- - -## Final checklist before uploading the video - -Use this as a last gate. **Every** item must be true or the rejection comes back. - -### Compliance items demonstrated -- [ ] Creator nickname visible on the upload page -- [ ] Preview of content before publishing -- [ ] Privacy dropdown uses API values (not a static preset) -- [ ] Privacy has no default — user selects -- [ ] Comment / Duet / Stitch all unchecked by default -- [ ] Greyed-out interaction (shown at least once if your account has it) -- [ ] Commercial disclosure toggle default OFF -- [ ] "Your brand" sub-toggle revealed, label "Promotional content" -- [ ] "Branded content" sub-toggle, label "Paid partnership" -- [ ] "Music Usage Confirmation" text + link visible (hover the link) -- [ ] "Branded Content Policy" text + link (when branded content) -- [ ] Publish button disabled while disclose ON + no sub-toggle picked -- [ ] SELF_ONLY (Only me) removed when Branded Content is on -- [ ] Caption/title fully user-editable, no auto-presets -- [ ] Post-publish "may take a few minutes to process" notification -- [ ] Content is original (recorded by you, not reposted) - -### What NOT to show -- [ ] No localhost or `.test` domain in the URL bar -- [ ] No dev tools consoles open (unless briefly for the creator_info call) -- [ ] No watermarks/promotional overlays added by trypost -- [ ] No reposted content from other platforms -- [ ] No "Other Apps / tools we compete with" references -- [ ] No preset hashtags or AI-generated caption that the user didn't edit - -### Technical -- [ ] Video resolution ≥ 1080p -- [ ] Clear, slow narration in English -- [ ] Cursor visible at each click -- [ ] Total length 2–4 minutes -- [ ] Exported as mp4, < 100MB - ---- - -## Why the last submission was rejected (so you know what changed) - -Based on the doc, the previous build likely violated: -1. Privacy level had a default (`SELF_ONLY`) -2. Comments checkbox was pre-checked -3. No "Paid partnership" label when branded content selected -4. No block on SELF_ONLY + branded content -5. Publish button not disabled when disclose ON without sub-toggle -6. No creator_info fetched — interactions & privacy options were static -7. No max-duration check -8. No processing-time notification - -All addressed in this build. The video above deliberately demonstrates each of these fixes in order. - ---- - -## Submission notes - -When submitting on TikTok's developer portal for the **Direct Post API audit**: -- Paste a direct link to the video (YouTube unlisted, Loom, or upload in the form) -- In the text field, reference this doc: "See attached video demonstrating compliance with Content Sharing Guidelines sections: creator_info fetch, mandatory metadata, commercial content disclosure labels, privacy restrictions for branded content, publish-button gating, processing notification." -- The video intentionally does not include the OAuth/authentication flow, which falls under the Login Kit audit, not Direct Post API. -- If asked about unaudited-client-restrictions: confirm your test accounts are currently private and posts went to SELF_ONLY during development. - ---- - -# 📋 Form Answers (copy / paste) - -## Describe your organization's work as it relates to TikTok - -trypost is a social media scheduling platform that helps authentic creators, small businesses, and agencies plan, schedule, and publish original content across multiple social networks from a single workspace. Our integration with TikTok enables users to compose and schedule short-form video content for their own TikTok accounts, select per-post settings (privacy level, interaction permissions, commercial disclosure) in full compliance with TikTok's Content Sharing Guidelines, preview content before publishing, and manage multiple TikTok accounts side by side — each account's creator_info (privacy options, interaction rules, max video duration) is respected independently. - -We do not repost content from other platforms, inject promotional watermarks, or automate content without explicit user action. Every post is composed, reviewed, and published only upon the user's explicit confirmation. Our role is purely to give creators a better scheduling workflow for content they already own. - -## Explain the goal of your application and how Content Posting API integration can be beneficial - -trypost helps creators and agencies publish original content consistently across social networks from one workspace, so they can focus on content instead of logging into each platform daily. The Content Posting API is essential because it lets us publish directly to TikTok at scheduled times, fetch creator_info at post time so each account's privacy options, interaction rules and max video duration are respected, and enforce TikTok's Content Sharing Guidelines in the UI — including the commercial disclosure flow, the "Promotional content" / "Paid partnership" labels, and the Music Usage and Branded Content Policy declarations. This benefits TikTok by ensuring uploads go through official endpoints (PULL_FROM_URL, status polling, token refresh), and commercial content is correctly disclosed before it reaches the platform. - -## Explain how you determined the daily usage estimate (less than 100) - -trypost launched publicly very recently, so our active user base is still small. Our current sign-up volume and TikTok account connection rate put realistic daily publishing on TikTok in the low double digits at most, with clear headroom before approaching 100. We chose this tier because it reflects actual observed usage, not a projection we cannot yet back with data. When real traction pushes us close to the cap, we will reapply with concrete numbers from our analytics to request a higher tier. - -## Please list the API response data fields that your API client will save in its database - -From /v2/oauth/token/ and /v2/user/info/ (social_accounts table): -- open_id (stored as platform_user_id) -- display_name -- username -- avatar_url (image copied to our storage) -- access_token (encrypted at rest) -- refresh_token (encrypted at rest) -- expires_in (converted to a timestamp) -- granted scopes - -From /v2/post/publish/video/init/, /content/init/ and /status/fetch/ (post_platforms table): -- publish_id -- publicaly_available_post_id - -Responses from /v2/post/publish/creator_info/query/ and analytics endpoints are fetched on demand and not persisted. diff --git a/app/Actions/Post/CreatePost.php b/app/Actions/Post/CreatePost.php index 413bdfbe..53081a70 100644 --- a/app/Actions/Post/CreatePost.php +++ b/app/Actions/Post/CreatePost.php @@ -9,26 +9,82 @@ use App\Models\User; use App\Models\Workspace; use Carbon\Carbon; +use Illuminate\Support\Facades\DB; class CreatePost { + /** + * Create a Post with optional platform selection. + * + * `platforms[]` enables specific social accounts. Each entry takes + * `social_account_id` and an optional `content_type` (defaults to the + * platform's default). Accounts not listed remain disabled but are still + * created via SyncPostPlatforms so the user can toggle them later in the + * editor. + * + * `label_ids[]` are attached after creation so the same set of UUIDs + * works for REST, MCP, and web callers. + * + * @param array{ + * content?: ?string, + * media?: array, + * date?: ?string, + * scheduled_at?: ?string, + * platforms?: array, + * label_ids?: array + * } $data + */ public static function execute(Workspace $workspace, User $user, array $data): Post { + $scheduledAt = self::resolveScheduledAt($data); + + return DB::transaction(function () use ($workspace, $user, $data, $scheduledAt): Post { + $post = $workspace->posts()->create([ + 'user_id' => $user->id, + 'content' => data_get($data, 'content', ''), + 'media' => data_get($data, 'media', []), + 'status' => PostStatus::Draft, + 'scheduled_at' => $scheduledAt, + ]); + + SyncPostPlatforms::execute($post); + + foreach (data_get($data, 'platforms', []) as $platformData) { + $accountId = data_get($platformData, 'social_account_id'); + if (! $accountId) { + continue; + } + + $updates = ['enabled' => true]; + + if ($contentType = data_get($platformData, 'content_type')) { + $updates['content_type'] = $contentType; + } + + $post->postPlatforms() + ->where('social_account_id', $accountId) + ->update($updates); + } + + if ($labelIds = data_get($data, 'label_ids')) { + $post->labels()->sync($labelIds); + } + + return $post; + }); + } + + /** + * @param array $data + */ + private static function resolveScheduledAt(array $data): Carbon + { + if ($scheduledAt = data_get($data, 'scheduled_at')) { + return Carbon::parse($scheduledAt)->utc(); + } + $date = data_get($data, 'date') ?: Carbon::now('UTC')->format('Y-m-d'); - $scheduledAt = Carbon::parse($date, 'UTC') - ->setTime(9, 0) - ->utc(); - $post = $workspace->posts()->create([ - 'user_id' => $user->id, - 'content' => data_get($data, 'content', ''), - 'media' => data_get($data, 'media', []), - 'status' => PostStatus::Draft, - 'scheduled_at' => $scheduledAt, - ]); - - SyncPostPlatforms::execute($post); - - return $post; + return Carbon::parse($date, 'UTC')->setTime(9, 0)->utc(); } } diff --git a/app/Actions/Post/UpdatePost.php b/app/Actions/Post/UpdatePost.php index ef40bd96..25612ff1 100644 --- a/app/Actions/Post/UpdatePost.php +++ b/app/Actions/Post/UpdatePost.php @@ -42,29 +42,31 @@ public static function execute(Workspace $workspace, Post $post, array $data): a $post->labels()->sync(data_get($data, 'label_ids', [])); } - DB::transaction(function () use ($post, $data) { - $post->postPlatforms()->update(['enabled' => false]); + if (Arr::has($data, 'platforms')) { + DB::transaction(function () use ($post, $data) { + $post->postPlatforms()->update(['enabled' => false]); - foreach (data_get($data, 'platforms', []) as $platformData) { - $updateData = ['enabled' => true]; + foreach (data_get($data, 'platforms', []) as $platformData) { + $updateData = ['enabled' => true]; - if (data_get($platformData, 'content_type') !== null) { - $updateData['content_type'] = data_get($platformData, 'content_type'); - } - - if (data_get($platformData, 'meta') !== null) { - $postPlatform = $post->postPlatforms()->where('id', data_get($platformData, 'id'))->first(); - - if ($postPlatform) { - $updateData['meta'] = array_merge($postPlatform->meta ?? [], data_get($platformData, 'meta')); + if (data_get($platformData, 'content_type') !== null) { + $updateData['content_type'] = data_get($platformData, 'content_type'); } - } - $post->postPlatforms() - ->where('id', data_get($platformData, 'id')) - ->update($updateData); - } - }); + if (data_get($platformData, 'meta') !== null) { + $postPlatform = $post->postPlatforms()->where('id', data_get($platformData, 'id'))->first(); + + if ($postPlatform) { + $updateData['meta'] = array_merge($postPlatform->meta ?? [], data_get($platformData, 'meta')); + } + } + + $post->postPlatforms() + ->where('id', data_get($platformData, 'id')) + ->update($updateData); + } + }); + } if ($status === PostStatus::Publishing->value) { $post->update(['scheduled_at' => now()]); diff --git a/app/Enums/Media/Type.php b/app/Enums/Media/Type.php index 2c942dc1..935da839 100644 --- a/app/Enums/Media/Type.php +++ b/app/Enums/Media/Type.php @@ -8,32 +8,80 @@ enum Type: string { case Image = 'image'; case Video = 'video'; - case Document = 'document'; public function label(): string { return match ($this) { self::Image => 'Imagem', self::Video => 'Vídeo', - self::Document => 'Documento', }; } + /** + * Allow-list of MIME types we accept on upload / URL fetch. + * + * Video accepts MP4 plus QuickTime/MOV. Modern .mov files (iPhone + * recordings, screen captures) are ISO BMFF containers — the same + * format MP4 uses — so social platforms decode them like MP4 even + * if PHP reports `video/quicktime`. Accepting MOV avoids forcing + * iPhone users to transcode before uploading. + * + * WebM is rejected: X / IG / TikTok / FB / Pinterest / Bluesky / + * Threads all reject the Matroska + VP8/VP9 stack. Without + * server-side transcoding, accepting WebM would just produce + * platform-specific publish failures down the line. + * + * @return array + */ public function allowedMimeTypes(): array { return match ($this) { self::Image => ['image/jpeg', 'image/png', 'image/gif', 'image/webp'], - self::Video => ['video/mp4', 'video/quicktime', 'video/webm'], - self::Document => ['application/pdf'], + self::Video => ['video/mp4', 'video/quicktime'], + }; + } + + /** + * Filename extensions that match this type. Mirrors allowedMimeTypes + * for callers that validate by name instead of MIME. + * + * @return array + */ + public function extensions(): array + { + return match ($this) { + self::Image => ['jpg', 'jpeg', 'png', 'gif', 'webp'], + self::Video => ['mp4', 'mov'], }; } public function maxSizeInMb(): int { - return match ($this) { - self::Image => 10, - self::Video => 2048, - self::Document => 100, - }; + return (int) config("trypost.media.max_size_mb.{$this->value}"); + } + + public function maxSizeInBytes(): int + { + return $this->maxSizeInMb() * 1024 * 1024; + } + + public function maxSizeInKb(): int + { + return $this->maxSizeInMb() * 1024; + } + + /** + * Resolve a Type from a MIME string. Returns null when the MIME is + * not in any type's allow-list. + */ + public static function fromMime(string $mime): ?self + { + foreach (self::cases() as $type) { + if (in_array($mime, $type->allowedMimeTypes(), true)) { + return $type; + } + } + + return null; } } diff --git a/app/Enums/PostPlatform/ContentType.php b/app/Enums/PostPlatform/ContentType.php index 56973159..15325a99 100644 --- a/app/Enums/PostPlatform/ContentType.php +++ b/app/Enums/PostPlatform/ContentType.php @@ -264,15 +264,39 @@ public static function aiSupported(): array } /** - * Get all content types for a specific platform. + * Platforms this content_type can be assigned to. Most content types are + * tied to a single platform; Instagram-family types (feed/carousel/reel/ + * story) work for both `Instagram` (Basic Display) and `InstagramFacebook` + * (Business via Facebook Page) accounts. + * + * @return array + */ + public function compatiblePlatforms(): array + { + $primary = $this->platform(); + + return match ($primary) { + SocialPlatform::Instagram => [SocialPlatform::Instagram, SocialPlatform::InstagramFacebook], + default => [$primary], + }; + } + + /** + * Get all content types for a specific platform. Treats InstagramFacebook + * as an alias for Instagram so both flavors get the same content types. * * @return array */ public static function forPlatform(SocialPlatform $platform): array { + $effective = match ($platform) { + SocialPlatform::InstagramFacebook => SocialPlatform::Instagram, + default => $platform, + }; + return array_filter( self::cases(), - fn (self $type) => $type->platform() === $platform + fn (self $type) => $type->platform() === $effective ); } diff --git a/app/Enums/SocialAccount/Platform.php b/app/Enums/SocialAccount/Platform.php index ae93a5a5..264db101 100644 --- a/app/Enums/SocialAccount/Platform.php +++ b/app/Enums/SocialAccount/Platform.php @@ -59,7 +59,7 @@ public function color(): string public function allowedMediaTypes(): array { return match ($this) { - self::LinkedIn, self::LinkedInPage => [MediaType::Image, MediaType::Video, MediaType::Document], + self::LinkedIn, self::LinkedInPage => [MediaType::Image, MediaType::Video], self::X => [MediaType::Image, MediaType::Video], self::TikTok => [MediaType::Video], self::YouTube => [MediaType::Video], diff --git a/app/Http/Controllers/Api/PlatformController.php b/app/Http/Controllers/Api/PlatformController.php new file mode 100644 index 00000000..0ec9edf1 --- /dev/null +++ b/app/Http/Controllers/Api/PlatformController.php @@ -0,0 +1,24 @@ +json([ + 'platforms' => PlatformContentTypesResource::collection(Platform::cases())->resolve(), + ]); + } +} diff --git a/app/Http/Controllers/Api/PostController.php b/app/Http/Controllers/Api/PostController.php index 3f6f4ab2..59f7e9fc 100644 --- a/app/Http/Controllers/Api/PostController.php +++ b/app/Http/Controllers/Api/PostController.php @@ -8,10 +8,15 @@ use App\Actions\Post\DeletePost; use App\Actions\Post\UpdatePost; use App\Enums\Post\Action as PostAction; +use App\Http\Requests\Api\Post\AttachMediaRequest; use App\Http\Requests\Api\Post\StorePostRequest; use App\Http\Requests\Api\Post\UpdatePostRequest; +use App\Http\Resources\Api\PostMediaAttachResource; +use App\Http\Resources\Api\PostMetricsResource; +use App\Http\Resources\Api\PostPreviewResource; use App\Http\Resources\Api\PostResource; use App\Models\Post; +use App\Services\Post\MediaAttacher; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\AnonymousResourceCollection; @@ -31,9 +36,7 @@ public function index(Request $request): AnonymousResourceCollection public function show(Request $request, Post $post): PostResource { - if ($post->workspace_id !== $request->user()->currentWorkspace->id) { - abort(Response::HTTP_NOT_FOUND); - } + $this->authorize('view', $post); $post->load(['postPlatforms.socialAccount', 'user', 'labels']); @@ -57,9 +60,7 @@ public function store(StorePostRequest $request): JsonResponse public function update(UpdatePostRequest $request, Post $post): PostResource|JsonResponse { - if ($post->workspace_id !== $request->user()->currentWorkspace->id) { - abort(Response::HTTP_NOT_FOUND); - } + $this->authorize('update', $post); $result = UpdatePost::execute($request->user()->currentWorkspace, $post, $request->validated()); @@ -75,12 +76,39 @@ public function update(UpdatePostRequest $request, Post $post): PostResource|Jso public function destroy(Request $request, Post $post): JsonResponse { - if ($post->workspace_id !== $request->user()->currentWorkspace->id) { - abort(Response::HTTP_NOT_FOUND); - } + $this->authorize('delete', $post); DeletePost::execute($post); return response()->json(null, Response::HTTP_NO_CONTENT); } + + public function attachMedia(AttachMediaRequest $request, Post $post): PostMediaAttachResource + { + $this->authorize('update', $post); + + $result = app(MediaAttacher::class)->attachFromUrls($post, $request->validated('urls')); + + $post->refresh()->load(['postPlatforms.socialAccount', 'labels']); + + return new PostMediaAttachResource($post, $result); + } + + public function metrics(Request $request, Post $post): PostMetricsResource + { + $this->authorize('view', $post); + + $post->load(['postPlatforms.socialAccount']); + + return new PostMetricsResource($post); + } + + public function preview(Request $request, Post $post): PostPreviewResource + { + $this->authorize('view', $post); + + $post->load(['postPlatforms.socialAccount']); + + return new PostPreviewResource($post); + } } diff --git a/app/Http/Controllers/App/AssetController.php b/app/Http/Controllers/App/AssetController.php index 8942e0b8..eab0588d 100644 --- a/app/Http/Controllers/App/AssetController.php +++ b/app/Http/Controllers/App/AssetController.php @@ -6,6 +6,7 @@ use App\Http\Requests\App\Asset\StoreAssetFromUrlRequest; use App\Http\Requests\App\Asset\StoreAssetRequest; +use App\Http\Requests\App\Asset\StoreChunkedAssetRequest; use App\Http\Resources\App\MediaResource; use App\Models\Media; use App\Services\UnsplashService; @@ -66,33 +67,17 @@ public function store(StoreAssetRequest $request): MediaResource return new MediaResource($media); } - public function storeChunked(Request $request): JsonResponse + public function storeChunked(StoreChunkedAssetRequest $request): JsonResponse { $workspace = $request->user()->currentWorkspace; $this->authorize('createPost', $workspace); - $contentRange = $request->header('Content-Range'); + $rangeStart = (int) $request->validated('range_start'); + $rangeEnd = (int) $request->validated('range_end'); + $totalSize = (int) $request->validated('total_size'); + $fileName = (string) $request->validated('file_name'); - preg_match('/bytes (\d+)-(\d+)\/(\d+)/', $contentRange, $matches); - - if (empty($matches)) { - abort(SymfonyResponse::HTTP_BAD_REQUEST, 'Invalid Content-Range header'); - } - - $rangeStart = (int) $matches[1]; - $rangeEnd = (int) $matches[2]; - $totalSize = (int) $matches[3]; - - $fileName = $request->header('X-File-Name', 'upload'); - - if (! preg_match('/\.(jpe?g|png|gif|webp|mp4)$/i', $fileName)) { - abort(SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'File type not supported.'); - } - - if ($totalSize > 1073741824) { // 1GB - abort(SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'File size exceeds the maximum allowed (1GB).'); - } $identifier = md5($request->user()->id.$fileName.$totalSize); $tempFile = storage_path("app/private/chunks/{$identifier}"); diff --git a/app/Http/Controllers/App/PostAiCreateController.php b/app/Http/Controllers/App/PostAiCreateController.php index 84dcbd20..cac14ec8 100644 --- a/app/Http/Controllers/App/PostAiCreateController.php +++ b/app/Http/Controllers/App/PostAiCreateController.php @@ -9,7 +9,6 @@ use App\Enums\PostPlatform\ContentType; use App\Http\Requests\App\Ai\StartPostCreationRequest; use App\Jobs\Ai\StreamPostCreation; -use App\Models\Media; use App\Models\SocialAccount; use App\Models\Workspace; use Illuminate\Http\JsonResponse; @@ -198,7 +197,9 @@ private function buildMediaArray(Workspace $workspace, array $state): array */ private function createMediaItem(Workspace $workspace, string $path, array $meta = []): array { - $media = new Media([ + // Use the relationship (not `mediable_type = Workspace::class`) so + // the morph map alias `'workspace'` is persisted instead of the FQCN. + $media = $workspace->media()->create([ 'collection' => 'ai-generated', 'type' => MediaType::Image, 'path' => $path, @@ -208,10 +209,6 @@ private function createMediaItem(Workspace $workspace, string $path, array $meta 'order' => 0, ]); - $media->mediable_type = Workspace::class; - $media->mediable_id = $workspace->id; - $media->save(); - return [ 'id' => $media->id, 'path' => $media->path, diff --git a/app/Http/Controllers/App/PostController.php b/app/Http/Controllers/App/PostController.php index d906ad95..b2b62409 100644 --- a/app/Http/Controllers/App/PostController.php +++ b/app/Http/Controllers/App/PostController.php @@ -18,22 +18,13 @@ use App\Http\Resources\App\SocialAccountResource; use App\Models\Post; use App\Models\PostPlatform; -use App\Services\Social\BlueskyAnalytics; -use App\Services\Social\FacebookAnalytics; -use App\Services\Social\InstagramAnalytics; -use App\Services\Social\LinkedInPageAnalytics; -use App\Services\Social\MastodonAnalytics; -use App\Services\Social\PinterestAnalytics; +use App\Services\Post\PostMetricsFetcher; use App\Services\Social\PinterestPublisher; -use App\Services\Social\ThreadsAnalytics; use App\Services\Social\TikTokCreatorInfo; -use App\Services\Social\XAnalytics; -use App\Services\Social\YouTubeAnalytics; use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Cache; use Inertia\Inertia; use Inertia\Response; @@ -174,38 +165,13 @@ public function store(Request $request): RedirectResponse|\Symfony\Component\Htt public function platformMetrics(Request $request, Post $post, PostPlatform $postPlatform): JsonResponse { - $workspace = $request->user()->currentWorkspace; - - if (! $workspace || $post->workspace_id !== $workspace->id) { - abort(404); - } - - $this->authorize('view', $workspace); + $this->authorize('view', $post); if ($postPlatform->post_id !== $post->id) { abort(404); } - if ($postPlatform->status->value !== 'published' || ! $postPlatform->platform_post_id) { - return response()->json(['unsupported' => true, 'reason' => 'not_published']); - } - - $cacheKey = "post_metrics:{$postPlatform->id}"; - - $metrics = Cache::remember($cacheKey, 300, fn () => match ($postPlatform->platform) { - Platform::X => app(XAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Bluesky => app(BlueskyAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Mastodon => app(MastodonAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Instagram, Platform::InstagramFacebook => app(InstagramAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Facebook => app(FacebookAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Threads => app(ThreadsAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::LinkedInPage => app(LinkedInPageAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::YouTube => app(YouTubeAnalytics::class)->fetchPostMetrics($postPlatform), - Platform::Pinterest => app(PinterestAnalytics::class)->fetchPostMetrics($postPlatform), - default => ['unsupported' => true, 'reason' => 'platform_not_supported'], - }); - - return response()->json($metrics); + return response()->json(app(PostMetricsFetcher::class)->forPlatform($postPlatform)); } public function show(Request $request, Post $post): Response|RedirectResponse @@ -216,11 +182,7 @@ public function show(Request $request, Post $post): Response|RedirectResponse return redirect()->route('app.workspaces.create'); } - $this->authorize('view', $workspace); - - if ($post->workspace_id !== $workspace->id) { - abort(404); - } + $this->authorize('view', $post); if (in_array($post->status, [PostStatus::Draft, PostStatus::Scheduled, PostStatus::Failed], true)) { return redirect()->route('app.posts.edit', $post); @@ -242,11 +204,7 @@ public function edit(Request $request, Post $post): Response|RedirectResponse return redirect()->route('app.workspaces.create'); } - $this->authorize('view', $workspace); - - if ($post->workspace_id !== $workspace->id) { - abort(404); - } + $this->authorize('update', $post); if (in_array($post->status, [PostStatus::Publishing, PostStatus::Published, PostStatus::PartiallyPublished], true)) { return redirect()->route('app.posts.show', $post); @@ -302,11 +260,7 @@ public function update(UpdatePostRequest $request, Post $post): RedirectResponse return redirect()->route('app.workspaces.create'); } - $this->authorize('createPost', $workspace); - - if ($post->workspace_id !== $workspace->id) { - abort(404); - } + $this->authorize('update', $post); $result = UpdatePost::execute($workspace, $post, $request->validated()); @@ -344,11 +298,7 @@ public function destroy(Request $request, Post $post): RedirectResponse return redirect()->route('app.workspaces.create'); } - $this->authorize('createPost', $workspace); - - if ($post->workspace_id !== $workspace->id) { - abort(404); - } + $this->authorize('delete', $post); if (in_array($post->status, [PostStatus::Publishing, PostStatus::Published, PostStatus::PartiallyPublished], true)) { session()->flash('flash.banner', __('posts.flash.cannot_delete_published')); diff --git a/app/Http/Controllers/App/PostTemplateController.php b/app/Http/Controllers/App/PostTemplateController.php index 86a80fca..a6de5061 100644 --- a/app/Http/Controllers/App/PostTemplateController.php +++ b/app/Http/Controllers/App/PostTemplateController.php @@ -7,7 +7,6 @@ use App\Actions\Post\CreatePost; use App\Enums\Media\Type as MediaType; use App\Http\Resources\App\PostTemplateResource; -use App\Models\Media; use App\Models\SocialAccount; use App\Models\Workspace; use App\Services\Image\TemplateImageGenerator; @@ -122,7 +121,9 @@ private function interpolate(string $text, Workspace $workspace): string */ private function createMediaItem(Workspace $workspace, string $path): array { - $media = new Media([ + // Use the relationship (not `mediable_type = Workspace::class`) so + // the morph map alias `'workspace'` is persisted instead of the FQCN. + $media = $workspace->media()->create([ 'collection' => 'ai-generated', 'type' => MediaType::Image, 'path' => $path, @@ -132,10 +133,6 @@ private function createMediaItem(Workspace $workspace, string $path): array 'order' => 0, ]); - $media->mediable_type = Workspace::class; - $media->mediable_id = $workspace->id; - $media->save(); - return [ 'id' => $media->id, 'path' => $media->path, diff --git a/app/Http/Requests/Api/Post/AttachMediaRequest.php b/app/Http/Requests/Api/Post/AttachMediaRequest.php new file mode 100644 index 00000000..4e2071c5 --- /dev/null +++ b/app/Http/Requests/Api/Post/AttachMediaRequest.php @@ -0,0 +1,26 @@ +> + */ + public function rules(): array + { + return [ + 'urls' => ['required', 'array', 'min:1', 'max:10'], + 'urls.*' => ['url:http,https', 'active_url'], + ]; + } +} diff --git a/app/Http/Requests/Api/Post/StorePostRequest.php b/app/Http/Requests/Api/Post/StorePostRequest.php index 51b66a29..be7a023a 100644 --- a/app/Http/Requests/Api/Post/StorePostRequest.php +++ b/app/Http/Requests/Api/Post/StorePostRequest.php @@ -4,8 +4,8 @@ namespace App\Http\Requests\Api\Post; -use App\Enums\Post\Status; use App\Enums\PostPlatform\ContentType; +use App\Rules\ContentTypeMatchesPlatform; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -18,13 +18,31 @@ public function authorize(): bool public function rules(): array { + $workspaceId = $this->user()->currentWorkspace->id; + return [ + 'content' => ['nullable', 'string', 'max:63206'], + 'media' => ['sometimes', 'array'], 'platforms' => ['required', 'array', 'min:1'], - 'platforms.*.social_account_id' => ['required', 'uuid', Rule::exists('social_accounts', 'id')->where('workspace_id', $this->user()->currentWorkspace->id)], - 'platforms.*.content_type' => ['required', 'string', Rule::in(array_column(ContentType::cases(), 'value'))], - 'platforms.*.content' => ['nullable', 'string', 'max:63206'], + 'platforms.*.social_account_id' => [ + 'required', + 'uuid', + Rule::exists('social_accounts', 'id') + ->where('workspace_id', $workspaceId) + ->where('is_active', true), + ], + 'platforms.*.content_type' => [ + 'required', + 'string', + Rule::in(array_column(ContentType::cases(), 'value')), + new ContentTypeMatchesPlatform, + ], 'scheduled_at' => ['nullable', 'date', 'after:now'], - 'status' => ['nullable', 'string', Rule::in(array_column(Status::cases(), 'value'))], + 'label_ids' => ['sometimes', 'array'], + 'label_ids.*' => [ + 'uuid', + Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspaceId), + ], ]; } } diff --git a/app/Http/Requests/Api/Post/UpdatePostRequest.php b/app/Http/Requests/Api/Post/UpdatePostRequest.php index b283660f..29fa072a 100644 --- a/app/Http/Requests/Api/Post/UpdatePostRequest.php +++ b/app/Http/Requests/Api/Post/UpdatePostRequest.php @@ -7,6 +7,7 @@ use App\Enums\Post\Status; use App\Enums\PostPlatform\ContentType; use App\Models\Post; +use App\Rules\ContentTypeMatchesPostPlatform; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -25,7 +26,12 @@ public function rules(): array 'media' => ['sometimes', 'array'], 'platforms' => ['sometimes', 'array'], 'platforms.*.id' => ['required', 'uuid', Rule::exists('post_platforms', 'id')->where('post_id', $this->route('post') instanceof Post ? $this->route('post')->id : $this->route('post'))], - 'platforms.*.content_type' => ['sometimes', 'string', Rule::in(array_column(ContentType::cases(), 'value'))], + 'platforms.*.content_type' => [ + 'sometimes', + 'string', + Rule::in(array_column(ContentType::cases(), 'value')), + new ContentTypeMatchesPostPlatform, + ], 'platforms.*.meta' => ['nullable', 'array'], 'scheduled_at' => [ 'nullable', diff --git a/app/Http/Requests/App/Asset/StoreAssetRequest.php b/app/Http/Requests/App/Asset/StoreAssetRequest.php index ef6f7154..7f649b0c 100644 --- a/app/Http/Requests/App/Asset/StoreAssetRequest.php +++ b/app/Http/Requests/App/Asset/StoreAssetRequest.php @@ -4,6 +4,7 @@ namespace App\Http\Requests\App\Asset; +use App\Enums\Media\Type as MediaType; use Illuminate\Foundation\Http\FormRequest; class StoreAssetRequest extends FormRequest @@ -15,8 +16,17 @@ public function authorize(): bool public function rules(): array { + $allowedMimes = [...MediaType::Image->allowedMimeTypes(), ...MediaType::Video->allowedMimeTypes()]; + return [ - 'media' => ['required', 'file', 'max:1048576', 'mimetypes:image/jpeg,image/png,image/gif,image/webp,video/mp4'], + // Use the largest per-type cap as the upper bound; per-type + // enforcement happens after the upload via the Media model. + 'media' => [ + 'required', + 'file', + 'max:'.MediaType::Video->maxSizeInKb(), + 'mimetypes:'.implode(',', $allowedMimes), + ], 'meta' => ['sometimes', 'array'], 'meta.width' => ['sometimes', 'integer', 'min:1'], 'meta.height' => ['sometimes', 'integer', 'min:1'], diff --git a/app/Http/Requests/App/Asset/StoreChunkedAssetRequest.php b/app/Http/Requests/App/Asset/StoreChunkedAssetRequest.php new file mode 100644 index 00000000..84ebf16f --- /dev/null +++ b/app/Http/Requests/App/Asset/StoreChunkedAssetRequest.php @@ -0,0 +1,68 @@ +header('Content-Range'), 'bytes %d-%d/%d') ?: []; + + $this->merge([ + 'range_start' => $parsed[0] ?? null, + 'range_end' => $parsed[1] ?? null, + 'total_size' => $parsed[2] ?? null, + // Lowercase the name so `ends_with` validation is effectively + // case-insensitive (IMG_1234.JPG vs img_1234.jpg). + 'file_name' => strtolower((string) $this->header('X-File-Name', 'upload')), + ]); + } + + /** + * @return array> + */ + public function rules(): array + { + $allowedSuffixes = collect([MediaType::Image, MediaType::Video]) + ->flatMap(fn (MediaType $type) => $type->extensions()) + ->map(fn (string $ext) => '.'.$ext) + ->all(); + + return [ + 'range_start' => ['required', 'integer', 'min:0'], + 'range_end' => ['required', 'integer', 'gte:range_start'], + 'total_size' => ['required', 'integer', 'min:1', 'max:'.MediaType::Video->maxSizeInBytes()], + 'file_name' => ['required', 'string', 'ends_with:'.implode(',', $allowedSuffixes)], + ]; + } + + /** + * @return array + */ + public function messages(): array + { + return [ + 'range_start.required' => 'Invalid Content-Range header', + 'range_end.required' => 'Invalid Content-Range header', + 'total_size.required' => 'Invalid Content-Range header', + 'total_size.max' => 'File size exceeds the maximum allowed ('.MediaType::Video->maxSizeInMb().' MB).', + 'file_name.ends_with' => 'File type not supported.', + ]; + } +} diff --git a/app/Http/Resources/Api/PlatformContentTypesResource.php b/app/Http/Resources/Api/PlatformContentTypesResource.php new file mode 100644 index 00000000..1082de9f --- /dev/null +++ b/app/Http/Resources/Api/PlatformContentTypesResource.php @@ -0,0 +1,50 @@ + + */ + public function toArray(Request $request): array + { + /** @var Platform $platform */ + $platform = $this->resource; + + return [ + 'platform' => $platform->value, + 'label' => $platform->label(), + 'max_content_length' => $platform->maxContentLength(), + 'recommended_content_length' => $platform->recommendedAiContentLength(), + 'allowed_media_types' => array_map( + fn ($type) => $type->value, + $platform->allowedMediaTypes(), + ), + 'default_content_type' => ContentType::defaultFor($platform)->value, + 'content_types' => array_map( + fn (ContentType $type) => [ + 'value' => $type->value, + 'label' => $type->label(), + 'description' => $type->description(), + 'max_media_count' => $type->maxMediaCount(), + 'requires_media' => $type->requiresMedia(), + ], + array_values(ContentType::forPlatform($platform)), + ), + ]; + } +} diff --git a/app/Http/Resources/Api/PostMediaAttachResource.php b/app/Http/Resources/Api/PostMediaAttachResource.php new file mode 100644 index 00000000..8c20d9d3 --- /dev/null +++ b/app/Http/Resources/Api/PostMediaAttachResource.php @@ -0,0 +1,36 @@ +>, failed: array} $result + */ + public function __construct(Post $post, private readonly array $result) + { + parent::__construct($post); + } + + /** + * @return array + */ + public function toArray(Request $request): array + { + return [ + 'post' => (new PostResource($this->resource))->resolve(), + 'attached_count' => count($this->result['attached']), + 'failed_urls' => $this->result['failed'], + ]; + } +} diff --git a/app/Http/Resources/Api/PostMetricsResource.php b/app/Http/Resources/Api/PostMetricsResource.php new file mode 100644 index 00000000..6724a00f --- /dev/null +++ b/app/Http/Resources/Api/PostMetricsResource.php @@ -0,0 +1,27 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'post_id' => $this->id, + 'platforms' => app(PostMetricsFetcher::class)->forPost($this->resource)->all(), + ]; + } +} diff --git a/app/Http/Resources/Api/PostPreviewResource.php b/app/Http/Resources/Api/PostPreviewResource.php new file mode 100644 index 00000000..3e524bdf --- /dev/null +++ b/app/Http/Resources/Api/PostPreviewResource.php @@ -0,0 +1,24 @@ + + */ + public function toArray(Request $request): array + { + return app(PostPreviewer::class)->forPost($this->resource); + } +} diff --git a/app/Mcp/Servers/TryPostServer.php b/app/Mcp/Servers/TryPostServer.php index 95a2e0d6..6bd9df35 100644 --- a/app/Mcp/Servers/TryPostServer.php +++ b/app/Mcp/Servers/TryPostServer.php @@ -11,10 +11,16 @@ use App\Mcp\Tools\Label\DeleteLabelTool; use App\Mcp\Tools\Label\ListLabelsTool; use App\Mcp\Tools\Label\UpdateLabelTool; +use App\Mcp\Tools\Platform\ListContentTypesTool; +use App\Mcp\Tools\Post\AttachMediaFromUrlTool; use App\Mcp\Tools\Post\CreatePostTool; use App\Mcp\Tools\Post\DeletePostTool; +use App\Mcp\Tools\Post\GetPostMetricsTool; use App\Mcp\Tools\Post\GetPostTool; use App\Mcp\Tools\Post\ListPostsTool; +use App\Mcp\Tools\Post\PreviewPostTool; +use App\Mcp\Tools\Post\PublishPostTool; +use App\Mcp\Tools\Post\UpdatePostTool; use App\Mcp\Tools\Signature\CreateSignatureTool; use App\Mcp\Tools\Signature\DeleteSignatureTool; use App\Mcp\Tools\Signature\ListSignaturesTool; @@ -39,7 +45,15 @@ class TryPostServer extends Server ListPostsTool::class, GetPostTool::class, CreatePostTool::class, + UpdatePostTool::class, + PublishPostTool::class, + PreviewPostTool::class, DeletePostTool::class, + AttachMediaFromUrlTool::class, + GetPostMetricsTool::class, + + // Platforms (read-only metadata) + ListContentTypesTool::class, // Signatures ListSignaturesTool::class, diff --git a/app/Mcp/Tools/Platform/ListContentTypesTool.php b/app/Mcp/Tools/Platform/ListContentTypesTool.php new file mode 100644 index 00000000..a7b3b632 --- /dev/null +++ b/app/Mcp/Tools/Platform/ListContentTypesTool.php @@ -0,0 +1,52 @@ + [ + 'value' => $type->value, + 'label' => $type->label(), + 'description' => $type->description(), + 'max_media_count' => $type->maxMediaCount(), + 'requires_media' => $type->requiresMedia(), + ], + array_values(ContentType::forPlatform($platform)), + ); + + $platforms[] = [ + 'platform' => $platform->value, + 'label' => $platform->label(), + 'max_content_length' => $platform->maxContentLength(), + 'recommended_content_length' => $platform->recommendedAiContentLength(), + 'allowed_media_types' => array_map( + fn ($type) => $type->value, + $platform->allowedMediaTypes(), + ), + 'default_content_type' => ContentType::defaultFor($platform)->value, + 'content_types' => $contentTypes, + ]; + } + + return Response::structured(['platforms' => $platforms]); + } +} diff --git a/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php new file mode 100644 index 00000000..97a00463 --- /dev/null +++ b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php @@ -0,0 +1,59 @@ +validate([ + 'post_id' => ['required', 'uuid'], + 'urls' => ['required', 'array', 'min:1', 'max:10'], + 'urls.*' => ['url:http,https', 'active_url'], + ]); + + $post = Post::where('workspace_id', $request->user()->current_workspace_id) + ->find(data_get($validated, 'post_id')); + + if (! $post) { + return Response::error('Post not found.'); + } + + $result = app(MediaAttacher::class)->attachFromUrls( + $post, + data_get($validated, 'urls', []), + ); + + $post->refresh()->load(['postPlatforms.socialAccount', 'labels']); + + return Response::structured([ + 'post' => (new PostResource($post))->resolve(), + 'attached_count' => count($result['attached']), + 'failed_urls' => $result['failed'], + ]); + } + + public function schema(JsonSchema $schema): array + { + return [ + 'post_id' => $schema->string()->required()->description('UUID of the post to attach media to.'), + 'urls' => $schema->array() + ->items($schema->string()) + ->required() + ->description('Public HTTP/HTTPS URLs of images or videos. Max 10 URLs per call, 50MB per file. Allowed types: image/jpeg, image/png, image/gif, image/webp, video/mp4, video/quicktime, video/webm.'), + ]; + } +} diff --git a/app/Mcp/Tools/Post/CreatePostTool.php b/app/Mcp/Tools/Post/CreatePostTool.php index 3350f8ed..df2a2f6a 100644 --- a/app/Mcp/Tools/Post/CreatePostTool.php +++ b/app/Mcp/Tools/Post/CreatePostTool.php @@ -5,29 +5,41 @@ namespace App\Mcp\Tools\Post; use App\Actions\Post\CreatePost; +use App\Enums\PostPlatform\ContentType; use App\Http\Resources\Api\PostResource; +use App\Rules\ContentTypeMatchesPlatform; use Illuminate\Contracts\JsonSchema\JsonSchema; +use Illuminate\Validation\Rule; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; use Laravel\Mcp\Server\Attributes\Description; use Laravel\Mcp\Server\Tool; -#[Description('Create a new draft post in the current workspace. The post is automatically attached to every active social account in the workspace (one PostPlatform per account).')] +#[Description('Create a draft post in the current workspace. Accepts content, scheduled_at, label_ids, and a list of platforms (social accounts to publish on, with their content_type). Use list-content-types-tool to discover valid content_types per platform.')] class CreatePostTool extends Tool { public function handle(Request $request): ResponseFactory { + $workspace = $request->user()->currentWorkspace; + $validated = $request->validate([ - 'content' => ['nullable', 'string'], - 'date' => ['nullable', 'date_format:Y-m-d'], + 'content' => ['nullable', 'string', 'max:63206'], + 'scheduled_at' => ['nullable', 'date', 'after:now'], + 'label_ids' => ['sometimes', 'array'], + 'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)], + 'platforms' => ['sometimes', 'array'], + 'platforms.*.social_account_id' => [ + 'required', + 'uuid', + Rule::exists('social_accounts', 'id') + ->where('workspace_id', $workspace->id) + ->where('is_active', true), + ], + 'platforms.*.content_type' => ['required', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPlatform], ]); - $post = CreatePost::execute( - $request->user()->currentWorkspace, - $request->user(), - $validated, - ); + $post = CreatePost::execute($workspace, $request->user(), $validated); $post->load(['postPlatforms.socialAccount', 'labels']); @@ -37,8 +49,17 @@ public function handle(Request $request): ResponseFactory public function schema(JsonSchema $schema): array { return [ - 'content' => $schema->string()->description('The post caption/text content. Optional — can be edited later.'), - 'date' => $schema->string()->description('Scheduled date as Y-m-d (e.g. 2026-05-10). Defaults to today. Time is fixed at 09:00 UTC; edit the post later for a specific time.'), + 'content' => $schema->string()->description('The post caption/text body. Optional — can be edited later.'), + 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future (e.g. 2026-05-10T15:30:00Z). Defaults to today at 09:00 UTC.'), + 'label_ids' => $schema->array() + ->items($schema->string()) + ->description('Workspace label IDs to attach to the post.'), + 'platforms' => $schema->array() + ->items($schema->object(fn ($p) => [ + 'social_account_id' => $p->string()->required()->description('UUID of the connected social account.'), + 'content_type' => $p->string()->required()->description('Format for this platform (e.g. linkedin_post, x_post, instagram_feed).'), + ])) + ->description('Platforms to publish on. Accounts not listed remain available but disabled.'), ]; } } diff --git a/app/Mcp/Tools/Post/GetPostMetricsTool.php b/app/Mcp/Tools/Post/GetPostMetricsTool.php new file mode 100644 index 00000000..b6ceb14f --- /dev/null +++ b/app/Mcp/Tools/Post/GetPostMetricsTool.php @@ -0,0 +1,47 @@ +validate([ + 'post_id' => ['required', 'uuid'], + ]); + + $post = Post::where('workspace_id', $request->user()->current_workspace_id) + ->with(['postPlatforms.socialAccount']) + ->find(data_get($validated, 'post_id')); + + if (! $post) { + return Response::error('Post not found.'); + } + + return Response::structured([ + 'post_id' => $post->id, + 'platforms' => app(PostMetricsFetcher::class)->forPost($post)->all(), + ]); + } + + public function schema(JsonSchema $schema): array + { + return [ + 'post_id' => $schema->string()->required()->description('UUID of the published post.'), + ]; + } +} diff --git a/app/Mcp/Tools/Post/ListPostsTool.php b/app/Mcp/Tools/Post/ListPostsTool.php index dcaea5e4..68d3bc5e 100644 --- a/app/Mcp/Tools/Post/ListPostsTool.php +++ b/app/Mcp/Tools/Post/ListPostsTool.php @@ -4,7 +4,10 @@ namespace App\Mcp\Tools\Post; +use App\Enums\Post\Status; use App\Http\Resources\Api\PostResource; +use Illuminate\Contracts\JsonSchema\JsonSchema; +use Illuminate\Validation\Rule; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\ResponseFactory; @@ -13,20 +16,55 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly; #[IsReadOnly] -#[Description('List posts for the current workspace, ordered by scheduled date (newest first).')] +#[Description('List posts for the current workspace, ordered by scheduled date (newest first). Optional filters: status (draft|scheduled|published) and search (matches against post content).')] class ListPostsTool extends Tool { public function handle(Request $request): ResponseFactory { - $posts = $request->user()->currentWorkspace + $validated = $request->validate([ + 'status' => ['sometimes', 'string', Rule::in([ + Status::Draft->value, + Status::Scheduled->value, + Status::Published->value, + Status::Failed->value, + ])], + 'search' => ['sometimes', 'string', 'max:255'], + 'limit' => ['sometimes', 'integer', 'min:1', 'max:100'], + ]); + + $query = $request->user()->currentWorkspace ->posts() - ->with(['postPlatforms.socialAccount', 'labels']) - ->latest('scheduled_at') - ->limit(50) + ->with(['postPlatforms.socialAccount', 'labels']); + + $query = match (data_get($validated, 'status')) { + Status::Draft->value => $query->draft(), + Status::Scheduled->value => $query->scheduled(), + Status::Published->value => $query->published(), + Status::Failed->value => $query->failed(), + default => $query, + }; + + if ($search = data_get($validated, 'search')) { + $query->where('content', 'ilike', '%'.$search.'%'); + } + + $posts = $query->latest('scheduled_at') + ->limit((int) data_get($validated, 'limit', 50)) ->get(); return Response::structured([ 'posts' => PostResource::collection($posts)->resolve(), ]); } + + public function schema(JsonSchema $schema): array + { + return [ + 'status' => $schema->string() + ->enum(['draft', 'scheduled', 'published', 'failed']) + ->description('Filter by status. "published" includes partially-published posts.'), + 'search' => $schema->string()->description('Case-insensitive substring match against the post content.'), + 'limit' => $schema->integer()->description('Max results (1-100, default 50).'), + ]; + } } diff --git a/app/Mcp/Tools/Post/PreviewPostTool.php b/app/Mcp/Tools/Post/PreviewPostTool.php new file mode 100644 index 00000000..f4ae064c --- /dev/null +++ b/app/Mcp/Tools/Post/PreviewPostTool.php @@ -0,0 +1,44 @@ +validate([ + 'post_id' => ['required', 'uuid'], + ]); + + $post = Post::where('workspace_id', $request->user()->current_workspace_id) + ->with(['postPlatforms.socialAccount']) + ->find(data_get($validated, 'post_id')); + + if (! $post) { + return Response::error('Post not found.'); + } + + return Response::structured(app(PostPreviewer::class)->forPost($post)); + } + + public function schema(JsonSchema $schema): array + { + return [ + 'post_id' => $schema->string()->required()->description('UUID of the post to preview.'), + ]; + } +} diff --git a/app/Mcp/Tools/Post/PublishPostTool.php b/app/Mcp/Tools/Post/PublishPostTool.php new file mode 100644 index 00000000..e27d9b39 --- /dev/null +++ b/app/Mcp/Tools/Post/PublishPostTool.php @@ -0,0 +1,68 @@ +user()->currentWorkspace; + + $validated = $request->validate([ + 'post_id' => ['required', 'uuid'], + 'scheduled_at' => ['nullable', 'date', 'after:now'], + ]); + + $post = Post::where('workspace_id', $workspace->id)->find(data_get($validated, 'post_id')); + + if (! $post) { + return Response::error('Post not found.'); + } + + if (! $post->postPlatforms()->where('enabled', true)->exists()) { + return Response::error('Post has no enabled platforms. Use update-post-tool to enable at least one platform first.'); + } + + $scheduledAt = data_get($validated, 'scheduled_at'); + + $result = UpdatePost::execute($workspace, $post, [ + 'status' => $scheduledAt ? Status::Scheduled->value : Status::Publishing->value, + 'scheduled_at' => $scheduledAt, + ]); + + if (data_get($result, 'action') === PostAction::AlreadyPublished) { + return Response::error('Post is already published.'); + } + + /** @var Post $updated */ + $updated = data_get($result, 'post'); + $updated->load(['postPlatforms.socialAccount', 'labels']); + + return Response::structured((new PostResource($updated))->resolve()); + } + + public function schema(JsonSchema $schema): array + { + return [ + 'post_id' => $schema->string()->required()->description('UUID of the post to publish.'), + 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future. If provided, the post is queued for that time. If omitted, publishing starts immediately.'), + ]; + } +} diff --git a/app/Mcp/Tools/Post/UpdatePostTool.php b/app/Mcp/Tools/Post/UpdatePostTool.php new file mode 100644 index 00000000..17d38ff7 --- /dev/null +++ b/app/Mcp/Tools/Post/UpdatePostTool.php @@ -0,0 +1,89 @@ +user()->currentWorkspace; + + $postId = data_get($request->all(), 'post_id'); + $post = is_string($postId) ? Post::where('workspace_id', $workspace->id)->find($postId) : null; + + if (! $post) { + return Response::error('Post not found.'); + } + + $validated = $request->validate([ + 'post_id' => ['required', 'uuid'], + 'content' => ['nullable', 'string', 'max:63206'], + 'scheduled_at' => ['nullable', 'date', 'after:now'], + 'status' => ['sometimes', 'string', Rule::in([Status::Draft->value, Status::Scheduled->value])], + 'label_ids' => ['sometimes', 'array'], + 'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)], + 'platforms' => ['sometimes', 'array'], + 'platforms.*.id' => [ + 'required', + 'uuid', + Rule::exists('post_platforms', 'id')->where('post_id', $post->id), + ], + 'platforms.*.content_type' => ['sometimes', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPostPlatform], + 'platforms.*.meta' => ['sometimes', 'array'], + ]); + + $payload = collect($validated)->except('post_id')->all(); + + $result = UpdatePost::execute($workspace, $post, $payload); + + if (data_get($result, 'action') === PostAction::AlreadyPublished) { + return Response::error('Cannot edit a published post.'); + } + + /** @var Post $updated */ + $updated = data_get($result, 'post'); + $updated->load(['postPlatforms.socialAccount', 'labels']); + + return Response::structured((new PostResource($updated))->resolve()); + } + + public function schema(JsonSchema $schema): array + { + return [ + 'post_id' => $schema->string()->required()->description('UUID of the post to update.'), + 'content' => $schema->string()->description('New caption/text body.'), + 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future. Required if status is "scheduled".'), + 'status' => $schema->string() + ->enum([Status::Draft->value, Status::Scheduled->value]) + ->description('Post status. Use "draft" to keep editing, "scheduled" to schedule the post. Use publish-post-tool for immediate publish.'), + 'label_ids' => $schema->array() + ->items($schema->string()) + ->description('Workspace label IDs to attach (replaces existing labels).'), + 'platforms' => $schema->array() + ->items($schema->object(fn ($p) => [ + 'id' => $p->string()->required()->description('UUID of the post_platform row (from get-post-tool / list-posts-tool).'), + 'content_type' => $p->string()->description('New content_type for this platform.'), + 'meta' => $p->object()->description('Per-platform metadata override (e.g. aspect_ratio, board_id for Pinterest).'), + ])) + ->description('Platforms to enable for publishing. Any platform NOT listed will be disabled. Pass an empty array to disable all.'), + ]; + } +} diff --git a/app/Models/Post.php b/app/Models/Post.php index 77328c36..04f0c9fe 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -5,6 +5,7 @@ namespace App\Models; use App\DataTransferObjects\MediaItem; +use App\Enums\Media\Type; use App\Enums\Post\Status as PostStatus; use Database\Factories\PostFactory; use Illuminate\Database\Eloquent\Builder; @@ -16,6 +17,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\DB; class Post extends Model { @@ -129,4 +131,50 @@ public function markAsFailed(): void { $this->update(['status' => PostStatus::Failed]); } + + /** + * MediaTypes accepted by this post — the intersection of what every + * enabled platform allows. With no platform enabled, accept anything. + * + * @return array + */ + public function allowedMediaTypes(): array + { + $platforms = $this->postPlatforms() + ->where('enabled', true) + ->with('socialAccount') + ->get() + ->pluck('socialAccount.platform') + ->filter(); + + if ($platforms->isEmpty()) { + return Type::cases(); + } + + $sets = $platforms + ->map(fn ($platform) => array_map(fn ($type) => $type->value, $platform->allowedMediaTypes())) + ->all(); + + return array_map( + Type::from(...), + array_values(array_intersect(...$sets)), + ); + } + + /** + * Append items to the JSON `media` column under a row lock so + * concurrent writers don't overwrite each other's appends. + * + * @param array> $items + */ + public function appendMedia(array $items): void + { + DB::transaction(function () use ($items): void { + $fresh = static::whereKey($this->id)->lockForUpdate()->first(); + $fresh->update([ + 'media' => collect($fresh->media ?? [])->concat($items)->all(), + ]); + $this->setRawAttributes($fresh->getAttributes(), true); + }); + } } diff --git a/app/Models/Traits/HasMedia.php b/app/Models/Traits/HasMedia.php index aaf32537..c1b9cb5e 100644 --- a/app/Models/Traits/HasMedia.php +++ b/app/Models/Traits/HasMedia.php @@ -164,7 +164,7 @@ private function getMediaType(string $mimeType): string return 'video'; } - return 'document'; + throw new \InvalidArgumentException("Unsupported media MIME type: {$mimeType}"); } private function getMediaMeta(UploadedFile $file, string $type): array diff --git a/app/Policies/PostPolicy.php b/app/Policies/PostPolicy.php index 9c41bd74..c89f8267 100644 --- a/app/Policies/PostPolicy.php +++ b/app/Policies/PostPolicy.php @@ -6,18 +6,58 @@ use App\Models\Post; use App\Models\User; +use Illuminate\Auth\Access\Response; class PostPolicy { /** - * Authorize duplicating a post into the user's current workspace as a - * fresh draft. The post must live in the user's current workspace and - * the user must have permission to create posts there. + * Authorize viewing a post. The post must live in the user's current + * workspace; cross-workspace lookups deny as 404 so we don't leak + * existence across tenants. */ - public function duplicate(User $user, Post $post): bool + public function view(User $user, Post $post): bool|Response { if ($post->workspace_id !== $user->current_workspace_id) { - return false; + return Response::denyAsNotFound(); + } + + return true; + } + + /** + * Authorize updating a post. Same workspace-tenancy guard as `view`. + */ + public function update(User $user, Post $post): bool|Response + { + if ($post->workspace_id !== $user->current_workspace_id) { + return Response::denyAsNotFound(); + } + + return true; + } + + /** + * Authorize deleting a post. Same workspace-tenancy guard as `view`. + */ + public function delete(User $user, Post $post): bool|Response + { + if ($post->workspace_id !== $user->current_workspace_id) { + return Response::denyAsNotFound(); + } + + return true; + } + + /** + * Authorize duplicating a post into the user's current workspace as a + * fresh draft. The post must live in the user's current workspace + * (404 otherwise — tenancy guard, see `view()`) AND the user must + * have permission to create posts there (403 otherwise). + */ + public function duplicate(User $user, Post $post): bool|Response + { + if ($post->workspace_id !== $user->current_workspace_id) { + return Response::denyAsNotFound(); } return $user->can('createPost', $user->currentWorkspace); diff --git a/app/Rules/ContentTypeMatchesPlatform.php b/app/Rules/ContentTypeMatchesPlatform.php new file mode 100644 index 00000000..56e945c2 --- /dev/null +++ b/app/Rules/ContentTypeMatchesPlatform.php @@ -0,0 +1,62 @@ + */ + private array $data = []; + + /** + * @param array $data + */ + public function setData(array $data): static + { + $this->data = $data; + + return $this; + } + + public function validate(string $attribute, mixed $value, Closure $fail): void + { + // attribute is e.g. "platforms.0.content_type" — peel off the leaf + // and look up the sibling social_account_id under the same parent. + $parentKey = Str::beforeLast($attribute, '.'); + $accountId = data_get($this->data, $parentKey.'.social_account_id'); + + if (! $accountId) { + return; + } + + $contentType = ContentType::tryFrom((string) $value); + $account = SocialAccount::find($accountId); + + if (! $contentType || ! $account) { + return; + } + + if (! in_array($account->platform, $contentType->compatiblePlatforms(), true)) { + $fail(sprintf( + 'content_type "%s" is not compatible with the %s account.', + $contentType->value, + $account->platform->label(), + )); + } + } +} diff --git a/app/Rules/ContentTypeMatchesPostPlatform.php b/app/Rules/ContentTypeMatchesPostPlatform.php new file mode 100644 index 00000000..b1fe924a --- /dev/null +++ b/app/Rules/ContentTypeMatchesPostPlatform.php @@ -0,0 +1,58 @@ + */ + private array $data = []; + + /** + * @param array $data + */ + public function setData(array $data): static + { + $this->data = $data; + + return $this; + } + + public function validate(string $attribute, mixed $value, Closure $fail): void + { + $parentKey = Str::beforeLast($attribute, '.'); + $postPlatformId = data_get($this->data, $parentKey.'.id'); + + if (! $postPlatformId) { + return; + } + + $contentType = ContentType::tryFrom((string) $value); + $postPlatform = PostPlatform::with('socialAccount')->find($postPlatformId); + + if (! $contentType || ! $postPlatform || ! $postPlatform->socialAccount) { + return; + } + + if (! in_array($postPlatform->socialAccount->platform, $contentType->compatiblePlatforms(), true)) { + $fail(sprintf( + 'content_type "%s" is not compatible with the %s account.', + $contentType->value, + $postPlatform->socialAccount->platform->label(), + )); + } + } +} diff --git a/app/Services/Post/MediaAttacher.php b/app/Services/Post/MediaAttacher.php new file mode 100644 index 00000000..6398a3ca --- /dev/null +++ b/app/Services/Post/MediaAttacher.php @@ -0,0 +1,128 @@ + $urls + * @return array{attached: array>, failed: array} + */ + public function attachFromUrls(Post $post, array $urls): array + { + $attached = []; + $failed = []; + + foreach ($urls as $url) { + ($item = $this->attachOne($post, $url)) === null + ? $failed[] = $url + : $attached[] = $item; + } + + if ($attached !== []) { + $post->appendMedia($attached); + } + + return ['attached' => $attached, 'failed' => $failed]; + } + + /** + * @return array|null + */ + private function attachOne(Post $post, string $url): ?array + { + $download = $this->download($url); + + if ($download === null) { + return null; + } + + try { + $type = MediaType::fromMime($download['mime'] ?? ''); + + if ($type === null || ! in_array($type, $post->allowedMediaTypes(), true)) { + return null; + } + + if ($download['bytes'] > $type->maxSizeInBytes()) { + return null; + } + + $name = basename(parse_url($url, PHP_URL_PATH) ?? '') ?: 'download.bin'; + $media = $post->workspace->addMediaFromPath($download['path'], $name, 'assets'); + + return [ + 'id' => $media->id, + 'path' => $media->path, + 'url' => $media->url, + 'type' => $media->type, + 'mime_type' => $media->mime_type, + 'original_filename' => $media->original_filename, + ]; + } finally { + @unlink($download['path']); + } + } + + /** + * Stream the URL to a temp file, aborting once we exceed the largest + * configured per-type cap (video). MIME is sniffed from the file's + * magic bytes — far more reliable than trusting the upstream + * `Content-Type` header (CDNs misconfigure, attackers spoof). + * + * @return array{path: string, mime: ?string, bytes: int}|null + */ + private function download(string $url): ?array + { + $cap = MediaType::Video->maxSizeInBytes(); + $temp = tempnam(sys_get_temp_dir(), 'media_'); + + try { + $response = Http::timeout(20) + ->sink($temp) + ->withOptions([ + 'allow_redirects' => false, + 'progress' => static function ($total, $downloaded) use ($cap): void { + if ($downloaded > $cap) { + throw new RuntimeException('exceeded max bytes'); + } + }, + ]) + ->get($url); + } catch (RuntimeException) { + @unlink($temp); + + return null; + } + + $bytes = filesize($temp) ?: 0; + + if (! $response->successful() || $bytes === 0) { + @unlink($temp); + + return null; + } + + return [ + 'path' => $temp, + 'mime' => mime_content_type($temp) ?: null, + 'bytes' => $bytes, + ]; + } +} diff --git a/app/Services/Post/PostMetricsFetcher.php b/app/Services/Post/PostMetricsFetcher.php new file mode 100644 index 00000000..9f6ba8c4 --- /dev/null +++ b/app/Services/Post/PostMetricsFetcher.php @@ -0,0 +1,76 @@ +|array{unsupported: true, reason: string} + * }> + */ + public function forPost(Post $post): Collection + { + return $post->postPlatforms + ->where('enabled', true) + ->values() + ->map(fn (PostPlatform $pp) => [ + 'post_platform_id' => $pp->id, + 'platform' => $pp->platform->value, + 'status' => $pp->status->value, + 'platform_post_id' => $pp->platform_post_id, + 'platform_url' => $pp->platform_url, + 'metrics' => $this->forPlatform($pp), + ]); + } + + /** + * @return array|array{unsupported: true, reason: string} + */ + public function forPlatform(PostPlatform $postPlatform): array + { + if ($postPlatform->status->value !== 'published' || ! $postPlatform->platform_post_id) { + return ['unsupported' => true, 'reason' => 'not_published']; + } + + return Cache::remember("post_metrics:{$postPlatform->id}", 300, fn () => match ($postPlatform->platform) { + Platform::X => app(XAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Bluesky => app(BlueskyAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Mastodon => app(MastodonAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Instagram, Platform::InstagramFacebook => app(InstagramAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Facebook => app(FacebookAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Threads => app(ThreadsAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::LinkedInPage => app(LinkedInPageAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::YouTube => app(YouTubeAnalytics::class)->fetchPostMetrics($postPlatform), + Platform::Pinterest => app(PinterestAnalytics::class)->fetchPostMetrics($postPlatform), + default => ['unsupported' => true, 'reason' => 'platform_not_supported'], + }); + } +} diff --git a/app/Services/Post/PostPreviewer.php b/app/Services/Post/PostPreviewer.php new file mode 100644 index 00000000..549491db --- /dev/null +++ b/app/Services/Post/PostPreviewer.php @@ -0,0 +1,73 @@ + + * } + */ + public function forPost(Post $post): array + { + $original = (string) $post->content; + + return [ + 'post_id' => $post->id, + 'original_content' => $original, + 'original_length' => mb_strlen($original), + 'platforms' => $this->platformPreviews($post, $original)->all(), + ]; + } + + /** + * @return Collection> + */ + private function platformPreviews(Post $post, string $original): Collection + { + return $post->postPlatforms + ->where('enabled', true) + ->values() + ->map(function (PostPlatform $pp) use ($original) { + $platform = $pp->socialAccount?->platform ?? $pp->platform; + $sanitized = $original === '' ? '' : $this->sanitizer->sanitize($original, $platform); + + return [ + 'post_platform_id' => $pp->id, + 'platform' => $platform->value, + 'content_type' => $pp->content_type?->value, + 'sanitized_content' => $sanitized, + 'sanitized_length' => mb_strlen($sanitized), + 'max_content_length' => $platform->maxContentLength(), + 'truncated' => mb_strlen($sanitized) < mb_strlen($original), + ]; + }); + } +} diff --git a/boost.json b/boost.json index 47c32a53..a4616e75 100644 --- a/boost.json +++ b/boost.json @@ -2,6 +2,7 @@ "agents": [ "claude_code" ], + "cloud": false, "guidelines": true, "mcp": true, "nightwatch_mcp": true, diff --git a/bootstrap/app.php b/bootstrap/app.php index 5629cb14..77e37ac5 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -15,7 +15,7 @@ ->withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', - apiPrefix: '', + apiPrefix: 'api', commands: __DIR__.'/../routes/console.php', channels: __DIR__.'/../routes/channels.php', health: '/up', diff --git a/composer.json b/composer.json index 702bd334..831fcd1f 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "threads", "pinterest" ], - "license": "MIT", + "license": "AGPL-3.0-only", "homepage": "https://trypost.it", "support": { "issues": "https://github.com/trypost-it/trypost/issues", @@ -41,7 +41,7 @@ "laravel/boost": "^2.0", "laravel/cashier": "^16.2", "laravel/framework": "^13.0", - "laravel/horizon": "^5.42", + "laravel/horizon": "^5.45", "laravel/mcp": "^0.6.4", "laravel/nightwatch": "^1.22", "laravel/passport": "^13.7", @@ -74,8 +74,7 @@ "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.6", "pestphp/pest": "^4.4", - "pestphp/pest-plugin-laravel": "^4.1", - "spatie/laravel-horizon-watcher": "^1.1" + "pestphp/pest-plugin-laravel": "^4.1" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index aff3be45..378c746f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "693f0a53ee57234d617d08bdb00774b7", + "content-hash": "3d3e5acee3f0e8b5df1dcfab91a2c6c0", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.379.0", + "version": "3.379.11", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "a50c3cc2c59f5ebeb56cbe170e6f144034b252b6" + "reference": "af784a64c1fc91c55bcfa493d8b92328bc3b38bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a50c3cc2c59f5ebeb56cbe170e6f144034b252b6", - "reference": "a50c3cc2c59f5ebeb56cbe170e6f144034b252b6", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/af784a64c1fc91c55bcfa493d8b92328bc3b38bf", + "reference": "af784a64c1fc91c55bcfa493d8b92328bc3b38bf", "shasum": "" }, "require": { @@ -153,9 +153,9 @@ "support": { "forum": "https://github.com/aws/aws-sdk-php/discussions", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.379.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.379.11" }, - "time": "2026-04-13T18:11:10+00:00" + "time": "2026-05-01T18:16:33+00:00" }, { "name": "brick/math", @@ -1112,16 +1112,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.437.0", + "version": "v0.440.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "1a7dd2368adb7ee4d5d07f828ae2dd7ecc43247c" + "reference": "f835f7a84611071ca2f58e8f44aac497d3aa7c44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/1a7dd2368adb7ee4d5d07f828ae2dd7ecc43247c", - "reference": "1a7dd2368adb7ee4d5d07f828ae2dd7ecc43247c", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/f835f7a84611071ca2f58e8f44aac497d3aa7c44", + "reference": "f835f7a84611071ca2f58e8f44aac497d3aa7c44", "shasum": "" }, "require": { @@ -1150,9 +1150,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.437.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.440.0" }, - "time": "2026-04-13T01:26:28+00:00" + "time": "2026-05-04T01:36:24+00:00" }, { "name": "google/auth", @@ -1833,16 +1833,16 @@ }, { "name": "intervention/image", - "version": "4.0.1", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/Intervention/image.git", - "reference": "f2fa8c7fc3e634c871d945fc83885548f75ef394" + "reference": "76d4e5a48b78f7b48f84d90160e6973b1e800832" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/f2fa8c7fc3e634c871d945fc83885548f75ef394", - "reference": "f2fa8c7fc3e634c871d945fc83885548f75ef394", + "url": "https://api.github.com/repos/Intervention/image/zipball/76d4e5a48b78f7b48f84d90160e6973b1e800832", + "reference": "76d4e5a48b78f7b48f84d90160e6973b1e800832", "shasum": "" }, "require": { @@ -1889,7 +1889,7 @@ ], "support": { "issues": "https://github.com/Intervention/image/issues", - "source": "https://github.com/Intervention/image/tree/4.0.1" + "source": "https://github.com/Intervention/image/tree/4.0.3" }, "funding": [ { @@ -1905,7 +1905,7 @@ "type": "ko_fi" } ], - "time": "2026-04-07T08:43:15+00:00" + "time": "2026-05-01T08:19:10+00:00" }, { "name": "laravel/ai", @@ -1977,16 +1977,16 @@ }, { "name": "laravel/boost", - "version": "v2.4.3", + "version": "v2.4.6", "source": { "type": "git", "url": "https://github.com/laravel/boost.git", - "reference": "841d52905728cfac9f93c778a1758e740ce9a367" + "reference": "c9ea6368c66f7c0e6a9b26706b401de900cdb9ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/boost/zipball/841d52905728cfac9f93c778a1758e740ce9a367", - "reference": "841d52905728cfac9f93c778a1758e740ce9a367", + "url": "https://api.github.com/repos/laravel/boost/zipball/c9ea6368c66f7c0e6a9b26706b401de900cdb9ac", + "reference": "c9ea6368c66f7c0e6a9b26706b401de900cdb9ac", "shasum": "" }, "require": { @@ -1995,7 +1995,7 @@ "illuminate/contracts": "^11.45.3|^12.41.1|^13.0", "illuminate/routing": "^11.45.3|^12.41.1|^13.0", "illuminate/support": "^11.45.3|^12.41.1|^13.0", - "laravel/mcp": "^0.5.1|^0.6.0", + "laravel/mcp": "^0.5.1|^0.6.0|^0.7.0", "laravel/prompts": "^0.3.10", "laravel/roster": "^0.5.0", "php": "^8.2" @@ -2039,7 +2039,7 @@ "issues": "https://github.com/laravel/boost/issues", "source": "https://github.com/laravel/boost" }, - "time": "2026-04-10T15:59:10+00:00" + "time": "2026-04-28T11:52:01+00:00" }, { "name": "laravel/cashier", @@ -2132,16 +2132,16 @@ }, { "name": "laravel/framework", - "version": "v13.5.0", + "version": "v13.7.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "ffa1850049a691b93129808f27ecd10e65c9d1a5" + "reference": "f13b85b2cce7ef5e8f3bcdf2b6c6364bbdedae0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/ffa1850049a691b93129808f27ecd10e65c9d1a5", - "reference": "ffa1850049a691b93129808f27ecd10e65c9d1a5", + "url": "https://api.github.com/repos/laravel/framework/zipball/f13b85b2cce7ef5e8f3bcdf2b6c6364bbdedae0b", + "reference": "f13b85b2cce7ef5e8f3bcdf2b6c6364bbdedae0b", "shasum": "" }, "require": { @@ -2184,6 +2184,7 @@ "symfony/mime": "^7.4.0 || ^8.0.0", "symfony/polyfill-php84": "^1.33", "symfony/polyfill-php85": "^1.33", + "symfony/polyfill-php86": "^1.36", "symfony/process": "^7.4.5 || ^8.0.5", "symfony/routing": "^7.4.0 || ^8.0.0", "symfony/uid": "^7.4.0 || ^8.0.0", @@ -2351,20 +2352,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2026-04-14T13:55:03+00:00" + "time": "2026-04-28T17:18:25+00:00" }, { "name": "laravel/horizon", - "version": "v5.45.6", + "version": "v5.46.0", "source": { "type": "git", "url": "https://github.com/laravel/horizon.git", - "reference": "629707ff3cce9ff72715e7815f74dda10bdcbe0a" + "reference": "bfea968e8aa674fb649d02e55ea0d38bdf5137d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/horizon/zipball/629707ff3cce9ff72715e7815f74dda10bdcbe0a", - "reference": "629707ff3cce9ff72715e7815f74dda10bdcbe0a", + "url": "https://api.github.com/repos/laravel/horizon/zipball/bfea968e8aa674fb649d02e55ea0d38bdf5137d5", + "reference": "bfea968e8aa674fb649d02e55ea0d38bdf5137d5", "shasum": "" }, "require": { @@ -2429,9 +2430,9 @@ ], "support": { "issues": "https://github.com/laravel/horizon/issues", - "source": "https://github.com/laravel/horizon/tree/v5.45.6" + "source": "https://github.com/laravel/horizon/tree/v5.46.0" }, - "time": "2026-04-14T13:31:53+00:00" + "time": "2026-04-20T18:08:11+00:00" }, { "name": "laravel/mcp", @@ -2753,16 +2754,16 @@ }, { "name": "laravel/prompts", - "version": "v0.3.16", + "version": "v0.3.17", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "11e7d5f93803a2190b00e145142cb00a33d17ad2" + "reference": "6a82ac19a28b916ae0885828795dbd4c59d9a818" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/11e7d5f93803a2190b00e145142cb00a33d17ad2", - "reference": "11e7d5f93803a2190b00e145142cb00a33d17ad2", + "url": "https://api.github.com/repos/laravel/prompts/zipball/6a82ac19a28b916ae0885828795dbd4c59d9a818", + "reference": "6a82ac19a28b916ae0885828795dbd4c59d9a818", "shasum": "" }, "require": { @@ -2806,9 +2807,9 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.16" + "source": "https://github.com/laravel/prompts/tree/v0.3.17" }, - "time": "2026-03-23T14:35:33+00:00" + "time": "2026-04-20T16:07:33+00:00" }, { "name": "laravel/reverb", @@ -3008,16 +3009,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v2.0.12", + "version": "v2.0.13", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "a6abb4e54f6fcd3138120b9ad497f0bd146f9919" + "reference": "b566ee0dd251f3c4078bed003a7ce015f5ea6dce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/a6abb4e54f6fcd3138120b9ad497f0bd146f9919", - "reference": "a6abb4e54f6fcd3138120b9ad497f0bd146f9919", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/b566ee0dd251f3c4078bed003a7ce015f5ea6dce", + "reference": "b566ee0dd251f3c4078bed003a7ce015f5ea6dce", "shasum": "" }, "require": { @@ -3065,20 +3066,20 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2026-04-14T13:33:34+00:00" + "time": "2026-04-16T14:03:50+00:00" }, { "name": "laravel/socialite", - "version": "v5.26.1", + "version": "v5.27.0", "source": { "type": "git", "url": "https://github.com/laravel/socialite.git", - "reference": "db6ec2ee967b7f06412c3a0cf1daaf072f4752a4" + "reference": "40e0757a75637c7b2dff05d3286b0d8fc25e5c0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/socialite/zipball/db6ec2ee967b7f06412c3a0cf1daaf072f4752a4", - "reference": "db6ec2ee967b7f06412c3a0cf1daaf072f4752a4", + "url": "https://api.github.com/repos/laravel/socialite/zipball/40e0757a75637c7b2dff05d3286b0d8fc25e5c0e", + "reference": "40e0757a75637c7b2dff05d3286b0d8fc25e5c0e", "shasum": "" }, "require": { @@ -3137,7 +3138,7 @@ "issues": "https://github.com/laravel/socialite/issues", "source": "https://github.com/laravel/socialite" }, - "time": "2026-03-29T14:50:53+00:00" + "time": "2026-04-24T14:05:47+00:00" }, { "name": "laravel/tinker", @@ -5441,16 +5442,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.51", + "version": "3.0.52", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "d59c94077f9c9915abb51ddb52ce85188ece1748" + "reference": "2adaefc83df2ec548558307690f376dd7d4f4fce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d59c94077f9c9915abb51ddb52ce85188ece1748", - "reference": "d59c94077f9c9915abb51ddb52ce85188ece1748", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/2adaefc83df2ec548558307690f376dd7d4f4fce", + "reference": "2adaefc83df2ec548558307690f376dd7d4f4fce", "shasum": "" }, "require": { @@ -5531,7 +5532,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.51" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.52" }, "funding": [ { @@ -5547,7 +5548,7 @@ "type": "tidelift" } ], - "time": "2026-04-10T01:33:53+00:00" + "time": "2026-04-27T07:02:15+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -5598,16 +5599,16 @@ }, { "name": "posthog/posthog-php", - "version": "4.2.0", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/PostHog/posthog-php.git", - "reference": "e1ca536ff60071d844cf65290bf63806b81bc386" + "reference": "d709d579c0b991b7628725078b2272c7e34a00e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PostHog/posthog-php/zipball/e1ca536ff60071d844cf65290bf63806b81bc386", - "reference": "e1ca536ff60071d844cf65290bf63806b81bc386", + "url": "https://api.github.com/repos/PostHog/posthog-php/zipball/d709d579c0b991b7628725078b2272c7e34a00e0", + "reference": "d709d579c0b991b7628725078b2272c7e34a00e0", "shasum": "" }, "require": { @@ -5634,7 +5635,7 @@ ], "authors": [ { - "name": "PostHog ", + "name": "PostHog ", "homepage": "https://posthog.com/" } ], @@ -5645,9 +5646,9 @@ ], "support": { "issues": "https://github.com/PostHog/posthog-php/issues", - "source": "https://github.com/PostHog/posthog-php/tree/4.2.0" + "source": "https://github.com/PostHog/posthog-php/tree/4.3.0" }, - "time": "2026-04-06T22:54:03+00:00" + "time": "2026-05-01T20:40:35+00:00" }, { "name": "predis/predis", @@ -7902,16 +7903,16 @@ }, { "name": "symfony/console", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5b66d385dc58f69652e56f78a4184615e3f2b7f7" + "reference": "7113778e2e91f4709cb3194a75dfa9c0d028d94d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5b66d385dc58f69652e56f78a4184615e3f2b7f7", - "reference": "5b66d385dc58f69652e56f78a4184615e3f2b7f7", + "url": "https://api.github.com/repos/symfony/console/zipball/7113778e2e91f4709cb3194a75dfa9c0d028d94d", + "reference": "7113778e2e91f4709cb3194a75dfa9c0d028d94d", "shasum": "" }, "require": { @@ -7968,7 +7969,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v8.0.8" + "source": "https://github.com/symfony/console/tree/v8.0.9" }, "funding": [ { @@ -7988,20 +7989,20 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-29T15:02:55+00:00" }, { "name": "symfony/css-selector", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "8db1c00226a94d8ab6aa89d9224eeee91e2ea2ed" + "reference": "3665cfade90565430909b906394c73c8739e57d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/8db1c00226a94d8ab6aa89d9224eeee91e2ea2ed", - "reference": "8db1c00226a94d8ab6aa89d9224eeee91e2ea2ed", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/3665cfade90565430909b906394c73c8739e57d0", + "reference": "3665cfade90565430909b906394c73c8739e57d0", "shasum": "" }, "require": { @@ -8037,7 +8038,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v8.0.8" + "source": "https://github.com/symfony/css-selector/tree/v8.0.9" }, "funding": [ { @@ -8057,7 +8058,7 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-18T13:51:42+00:00" }, { "name": "symfony/deprecation-contracts", @@ -8279,16 +8280,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "f662acc6ab22a3d6d716dcb44c381c6002940df6" + "reference": "0c3c1a17604c4dbbec4b93fe162c538482096e1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f662acc6ab22a3d6d716dcb44c381c6002940df6", - "reference": "f662acc6ab22a3d6d716dcb44c381c6002940df6", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/0c3c1a17604c4dbbec4b93fe162c538482096e1f", + "reference": "0c3c1a17604c4dbbec4b93fe162c538482096e1f", "shasum": "" }, "require": { @@ -8340,7 +8341,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v8.0.8" + "source": "https://github.com/symfony/event-dispatcher/tree/v8.0.9" }, "funding": [ { @@ -8360,7 +8361,7 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-18T13:51:42+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -8440,16 +8441,16 @@ }, { "name": "symfony/filesystem", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "66b769ae743ce2d13e435528fbef4af03d623e5a" + "reference": "d1ec4543d5c6c2dac78503c2fae5ea0b3608ce40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/66b769ae743ce2d13e435528fbef4af03d623e5a", - "reference": "66b769ae743ce2d13e435528fbef4af03d623e5a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/d1ec4543d5c6c2dac78503c2fae5ea0b3608ce40", + "reference": "d1ec4543d5c6c2dac78503c2fae5ea0b3608ce40", "shasum": "" }, "require": { @@ -8486,7 +8487,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v8.0.8" + "source": "https://github.com/symfony/filesystem/tree/v8.0.9" }, "funding": [ { @@ -8506,7 +8507,7 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-18T13:51:42+00:00" }, { "name": "symfony/finder", @@ -8842,16 +8843,16 @@ }, { "name": "symfony/mime", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "ddff21f14c7ce04b98101b399a9463dce8b0ce66" + "reference": "a9fcb293650c054b62a5b406f4e92e7b711ea333" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/ddff21f14c7ce04b98101b399a9463dce8b0ce66", - "reference": "ddff21f14c7ce04b98101b399a9463dce8b0ce66", + "url": "https://api.github.com/repos/symfony/mime/zipball/a9fcb293650c054b62a5b406f4e92e7b711ea333", + "reference": "a9fcb293650c054b62a5b406f4e92e7b711ea333", "shasum": "" }, "require": { @@ -8904,7 +8905,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v8.0.8" + "source": "https://github.com/symfony/mime/tree/v8.0.9" }, "funding": [ { @@ -8924,11 +8925,11 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-29T15:02:55+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -8987,7 +8988,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0" }, "funding": [ { @@ -9011,16 +9012,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "ad1b7b9092976d6c948b8a187cec9faaea9ec1df" + "reference": "4864388bfbd3001ce88e234fab652acd91fdc57e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/ad1b7b9092976d6c948b8a187cec9faaea9ec1df", - "reference": "ad1b7b9092976d6c948b8a187cec9faaea9ec1df", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/4864388bfbd3001ce88e234fab652acd91fdc57e", + "reference": "4864388bfbd3001ce88e234fab652acd91fdc57e", "shasum": "" }, "require": { @@ -9069,7 +9070,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.37.0" }, "funding": [ { @@ -9089,11 +9090,11 @@ "type": "tidelift" } ], - "time": "2026-04-10T16:19:22+00:00" + "time": "2026-04-26T13:13:48+00:00" }, { "name": "symfony/polyfill-intl-icu", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-icu.git", @@ -9157,7 +9158,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.37.0" }, "funding": [ { @@ -9181,7 +9182,7 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", @@ -9244,7 +9245,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.37.0" }, "funding": [ { @@ -9268,7 +9269,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -9329,7 +9330,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.37.0" }, "funding": [ { @@ -9353,7 +9354,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -9414,7 +9415,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.37.0" }, "funding": [ { @@ -9438,7 +9439,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -9498,7 +9499,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0" }, "funding": [ { @@ -9522,7 +9523,7 @@ }, { "name": "symfony/polyfill-php83", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php83.git", @@ -9578,7 +9579,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.37.0" }, "funding": [ { @@ -9602,7 +9603,7 @@ }, { "name": "symfony/polyfill-php84", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php84.git", @@ -9658,7 +9659,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php84/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-php84/tree/v1.37.0" }, "funding": [ { @@ -9682,16 +9683,16 @@ }, { "name": "symfony/polyfill-php85", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "2c408a6bb0313e6001a83628dc5506100474254e" + "reference": "fcfa4973a9917cef23f2e38774da74a2b7d115ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/2c408a6bb0313e6001a83628dc5506100474254e", - "reference": "2c408a6bb0313e6001a83628dc5506100474254e", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/fcfa4973a9917cef23f2e38774da74a2b7d115ee", + "reference": "fcfa4973a9917cef23f2e38774da74a2b7d115ee", "shasum": "" }, "require": { @@ -9738,7 +9739,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.37.0" }, "funding": [ { @@ -9758,11 +9759,91 @@ "type": "tidelift" } ], - "time": "2026-04-10T16:50:15+00:00" + "time": "2026-04-26T13:10:57+00:00" + }, + { + "name": "symfony/polyfill-php86", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php86.git", + "reference": "33d8fc5a705481e21fe3a81212b26f9b1f61749c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php86/zipball/33d8fc5a705481e21fe3a81212b26f9b1f61749c", + "reference": "33d8fc5a705481e21fe3a81212b26f9b1f61749c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php86\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.6+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php86/tree/v1.37.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-04-26T13:13:48+00:00" }, { "name": "symfony/polyfill-uuid", - "version": "v1.36.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-uuid.git", @@ -9821,7 +9902,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.36.0" + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.37.0" }, "funding": [ { @@ -9997,16 +10078,16 @@ }, { "name": "symfony/routing", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "0de330ec2ea922a7b08ec45615bd51179de7fda4" + "reference": "75d1bd8e5da3424e4db2fc3ff0222cb4d0c73038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/0de330ec2ea922a7b08ec45615bd51179de7fda4", - "reference": "0de330ec2ea922a7b08ec45615bd51179de7fda4", + "url": "https://api.github.com/repos/symfony/routing/zipball/75d1bd8e5da3424e4db2fc3ff0222cb4d0c73038", + "reference": "75d1bd8e5da3424e4db2fc3ff0222cb4d0c73038", "shasum": "" }, "require": { @@ -10053,7 +10134,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v8.0.8" + "source": "https://github.com/symfony/routing/tree/v8.0.9" }, "funding": [ { @@ -10073,7 +10154,7 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-29T15:02:55+00:00" }, { "name": "symfony/service-contracts", @@ -10429,16 +10510,16 @@ }, { "name": "symfony/uid", - "version": "v8.0.8", + "version": "v8.0.9", "source": { "type": "git", "url": "https://github.com/symfony/uid.git", - "reference": "f63fa6096a24147283bce4d29327d285326438e0" + "reference": "4d9d6510bbe88ebb4608b7200d18606cdf80825c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/uid/zipball/f63fa6096a24147283bce4d29327d285326438e0", - "reference": "f63fa6096a24147283bce4d29327d285326438e0", + "url": "https://api.github.com/repos/symfony/uid/zipball/4d9d6510bbe88ebb4608b7200d18606cdf80825c", + "reference": "4d9d6510bbe88ebb4608b7200d18606cdf80825c", "shasum": "" }, "require": { @@ -10483,7 +10564,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/uid/tree/v8.0.8" + "source": "https://github.com/symfony/uid/tree/v8.0.9" }, "funding": [ { @@ -10503,7 +10584,7 @@ "type": "tidelift" } ], - "time": "2026-03-30T15:14:47+00:00" + "time": "2026-04-30T16:10:06+00:00" }, { "name": "symfony/var-dumper", @@ -10808,23 +10889,23 @@ }, { "name": "voku/portable-ascii", - "version": "2.0.3", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/voku/portable-ascii.git", - "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d" + "reference": "8e1051fe39379367aecf014f41744ce7539a856f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b1d923f88091c6bf09699efcd7c8a1b1bfd7351d", - "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/8e1051fe39379367aecf014f41744ce7539a856f", + "reference": "8e1051fe39379367aecf014f41744ce7539a856f", "shasum": "" }, "require": { - "php": ">=7.0.0" + "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" + "phpunit/phpunit": "~8.5 || ~9.6 || ~10.5 || ~11.5" }, "suggest": { "ext-intl": "Use Intl for transliterator_transliterate() support" @@ -10854,7 +10935,7 @@ ], "support": { "issues": "https://github.com/voku/portable-ascii/issues", - "source": "https://github.com/voku/portable-ascii/tree/2.0.3" + "source": "https://github.com/voku/portable-ascii/tree/2.1.1" }, "funding": [ { @@ -10878,7 +10959,7 @@ "type": "tidelift" } ], - "time": "2024-11-21T01:49:47+00:00" + "time": "2026-04-26T05:33:54+00:00" } ], "packages-dev": [ @@ -10975,6 +11056,151 @@ ], "time": "2026-03-29T15:46:14+00:00" }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-05-06T16:37:16+00:00" + }, { "name": "doctrine/deprecations", "version": "1.1.6", @@ -11411,16 +11637,16 @@ }, { "name": "laravel/pint", - "version": "v1.29.0", + "version": "v1.29.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "bdec963f53172c5e36330f3a400604c69bf02d39" + "reference": "0770e9b7fafd50d4586881d456d6eb41c9247a80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/bdec963f53172c5e36330f3a400604c69bf02d39", - "reference": "bdec963f53172c5e36330f3a400604c69bf02d39", + "url": "https://api.github.com/repos/laravel/pint/zipball/0770e9b7fafd50d4586881d456d6eb41c9247a80", + "reference": "0770e9b7fafd50d4586881d456d6eb41c9247a80", "shasum": "" }, "require": { @@ -11431,14 +11657,14 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.94.2", - "illuminate/view": "^12.54.1", - "larastan/larastan": "^3.9.3", - "laravel-zero/framework": "^12.0.5", + "friendsofphp/php-cs-fixer": "^3.95.1", + "illuminate/view": "^12.56.0", + "larastan/larastan": "^3.9.6", + "laravel-zero/framework": "^12.1.0", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.4.0", "pestphp/pest": "^3.8.6", - "shipfastlabs/agent-detector": "^1.1.0" + "shipfastlabs/agent-detector": "^1.1.3" }, "bin": [ "builds/pint" @@ -11475,20 +11701,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2026-03-12T15:51:39+00:00" + "time": "2026-04-20T15:26:14+00:00" }, { "name": "laravel/sail", - "version": "v1.57.0", + "version": "v1.58.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "fa8d057b6e9310380ccbc3a209ed7f927d54f648" + "reference": "2e5e968138ca52ed87d712449697a8364d73b466" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/fa8d057b6e9310380ccbc3a209ed7f927d54f648", - "reference": "fa8d057b6e9310380ccbc3a209ed7f927d54f648", + "url": "https://api.github.com/repos/laravel/sail/zipball/2e5e968138ca52ed87d712449697a8364d73b466", + "reference": "2e5e968138ca52ed87d712449697a8364d73b466", "shasum": "" }, "require": { @@ -11538,7 +11764,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2026-04-14T13:32:04+00:00" + "time": "2026-04-27T13:38:34+00:00" }, { "name": "laravel/telescope", @@ -11754,23 +11980,23 @@ }, { "name": "nunomaduro/collision", - "version": "v8.9.3", + "version": "v8.9.4", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "b0d8ab95b29c3189aeeb902d81215231df4c1b64" + "reference": "716af8f95a470e9094cfca09ed897b023be191a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b0d8ab95b29c3189aeeb902d81215231df4c1b64", - "reference": "b0d8ab95b29c3189aeeb902d81215231df4c1b64", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/716af8f95a470e9094cfca09ed897b023be191a5", + "reference": "716af8f95a470e9094cfca09ed897b023be191a5", "shasum": "" }, "require": { "filp/whoops": "^2.18.4", "nunomaduro/termwind": "^2.4.0", "php": "^8.2.0", - "symfony/console": "^7.4.8 || ^8.0.4" + "symfony/console": "^7.4.8 || ^8.0.8" }, "conflict": { "laravel/framework": "<11.48.0 || >=14.0.0", @@ -11778,12 +12004,12 @@ }, "require-dev": { "brianium/paratest": "^7.8.5", - "larastan/larastan": "^3.9.3", - "laravel/framework": "^11.48.0 || ^12.56.0 || ^13.2.0", - "laravel/pint": "^1.29.0", - "orchestra/testbench-core": "^9.12.0 || ^10.12.1 || ^11.0.0", + "larastan/larastan": "^3.9.6", + "laravel/framework": "^11.48.0 || ^12.56.0 || ^13.5.0", + "laravel/pint": "^1.29.1", + "orchestra/testbench-core": "^9.12.0 || ^10.12.1 || ^11.2.1", "pestphp/pest": "^3.8.5 || ^4.4.3 || ^5.0.0", - "sebastian/environment": "^7.2.1 || ^8.0.4 || ^9.0.0" + "sebastian/environment": "^7.2.1 || ^8.0.4 || ^9.3.0" }, "type": "library", "extra": { @@ -11846,42 +12072,43 @@ "type": "patreon" } ], - "time": "2026-04-06T19:25:53+00:00" + "time": "2026-04-21T14:04:20+00:00" }, { "name": "pestphp/pest", - "version": "v4.6.1", + "version": "v4.7.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "87db0b484788cfde4778b715bb1fed34133685fa" + "reference": "2fc75cfcf03c041c804778fa894282234adc3c66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/87db0b484788cfde4778b715bb1fed34133685fa", - "reference": "87db0b484788cfde4778b715bb1fed34133685fa", + "url": "https://api.github.com/repos/pestphp/pest/zipball/2fc75cfcf03c041c804778fa894282234adc3c66", + "reference": "2fc75cfcf03c041c804778fa894282234adc3c66", "shasum": "" }, "require": { "brianium/paratest": "^7.20.0", - "nunomaduro/collision": "^8.9.3", + "composer/xdebug-handler": "^3.0.5", + "nunomaduro/collision": "^8.9.4", "nunomaduro/termwind": "^2.4.0", "pestphp/pest-plugin": "^4.0.0", "pestphp/pest-plugin-arch": "^4.0.2", "pestphp/pest-plugin-mutate": "^4.0.1", "pestphp/pest-plugin-profanity": "^4.2.1", "php": "^8.3.0", - "phpunit/phpunit": "^12.5.20", + "phpunit/phpunit": "^12.5.24", "symfony/process": "^7.4.8|^8.0.8" }, "conflict": { "filp/whoops": "<2.18.3", - "phpunit/phpunit": ">12.5.20", + "phpunit/phpunit": ">12.5.24", "sebastian/exporter": "<7.0.0", "webmozart/assert": "<1.11.0" }, "require-dev": { - "mrpunyapal/peststan": "^0.2.5", + "mrpunyapal/peststan": "^0.2.9", "pestphp/pest-dev-tools": "^4.1.0", "pestphp/pest-plugin-browser": "^4.3.1", "pestphp/pest-plugin-type-coverage": "^4.0.4", @@ -11912,6 +12139,7 @@ "Pest\\Plugins\\Verbose", "Pest\\Plugins\\Version", "Pest\\Plugins\\Shard", + "Pest\\Plugins\\Tia", "Pest\\Plugins\\Parallel" ] }, @@ -11951,7 +12179,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v4.6.1" + "source": "https://github.com/pestphp/pest/tree/v4.7.0" }, "funding": [ { @@ -11963,7 +12191,7 @@ "type": "github" } ], - "time": "2026-04-15T16:03:09+00:00" + "time": "2026-05-03T16:09:32+00:00" }, { "name": "pestphp/pest-plugin", @@ -12952,16 +13180,16 @@ }, { "name": "phpunit/phpunit", - "version": "12.5.20", + "version": "12.5.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c2364520611caa03567a8a020f2d59f3f90b115a" + "reference": "d75dd30597caa80e72fad2ef7904601a30ef1046" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c2364520611caa03567a8a020f2d59f3f90b115a", - "reference": "c2364520611caa03567a8a020f2d59f3f90b115a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d75dd30597caa80e72fad2ef7904601a30ef1046", + "reference": "d75dd30597caa80e72fad2ef7904601a30ef1046", "shasum": "" }, "require": { @@ -12975,7 +13203,7 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.3", - "phpunit/php-code-coverage": "^12.5.5", + "phpunit/php-code-coverage": "^12.5.6", "phpunit/php-file-iterator": "^6.0.1", "phpunit/php-invoker": "^6.0.0", "phpunit/php-text-template": "^5.0.0", @@ -12983,7 +13211,7 @@ "sebastian/cli-parser": "^4.2.0", "sebastian/comparator": "^7.1.6", "sebastian/diff": "^7.0.0", - "sebastian/environment": "^8.0.4", + "sebastian/environment": "^8.1.0", "sebastian/exporter": "^7.0.2", "sebastian/global-state": "^8.0.2", "sebastian/object-enumerator": "^7.0.0", @@ -13030,7 +13258,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.20" + "source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.24" }, "funding": [ { @@ -13038,7 +13266,7 @@ "type": "other" } ], - "time": "2026-04-15T05:05:59+00:00" + "time": "2026-05-01T04:21:04+00:00" }, { "name": "sebastian/cli-parser", @@ -13937,195 +14165,6 @@ ], "time": "2025-02-07T05:00:38+00:00" }, - { - "name": "spatie/file-system-watcher", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/spatie/file-system-watcher.git", - "reference": "2fe96de88af6660b3ab7658a8f1d41b10ad0aff6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/file-system-watcher/zipball/2fe96de88af6660b3ab7658a8f1d41b10ad0aff6", - "reference": "2fe96de88af6660b3ab7658a8f1d41b10ad0aff6", - "shasum": "" - }, - "require": { - "php": "^8.3", - "symfony/process": "^7.0|^8.0" - }, - "require-dev": { - "pestphp/pest": "^4.0", - "spatie/ray": "^1.22", - "spatie/temporary-directory": "^2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\Watcher\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "role": "Developer" - } - ], - "description": "Watch changes in the file system using PHP", - "homepage": "https://github.com/spatie/file-system-watcher", - "keywords": [ - "file-system-watcher", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/file-system-watcher/issues", - "source": "https://github.com/spatie/file-system-watcher/tree/1.2.1" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2025-11-26T10:41:42+00:00" - }, - { - "name": "spatie/laravel-horizon-watcher", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-horizon-watcher.git", - "reference": "ddd205838d75f9898a2b039b4397be3518cfac89" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-horizon-watcher/zipball/ddd205838d75f9898a2b039b4397be3518cfac89", - "reference": "ddd205838d75f9898a2b039b4397be3518cfac89", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^9.0|^10.0|^11.0|^12.0|^13.0", - "php": "^8.3", - "spatie/file-system-watcher": "^1.1.1", - "spatie/laravel-package-tools": "^1.13.6" - }, - "require-dev": { - "laravel/pint": "^1.2", - "nunomaduro/collision": "^6.3.1|^8.0", - "orchestra/testbench": "^7.11|^8.0|^9.0|^10.0|^11.0", - "pestphp/pest": "^1.22.1|^2.34|^3.7", - "pestphp/pest-plugin-laravel": "^1.3|^2.3|^3.1", - "phpunit/phpunit": "^9.5.26|^10.5|^11.5.3", - "spatie/laravel-ray": "^1.31" - }, - "type": "library", - "extra": { - "laravel": { - "aliases": { - "HorizonWatcher": "Spatie\\HorizonWatcher\\Facades\\HorizonWatcher" - }, - "providers": [ - "Spatie\\HorizonWatcher\\HorizonWatcherServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Spatie\\HorizonWatcher\\": "src", - "Spatie\\HorizonWatcher\\Database\\Factories\\": "database/factories" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "role": "Developer" - } - ], - "description": "Automatically restart Horizon when local PHP files change", - "homepage": "https://github.com/spatie/laravel-horizon-watcher", - "keywords": [ - "laravel", - "laravel-horizon-watcher", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/laravel-horizon-watcher/issues", - "source": "https://github.com/spatie/laravel-horizon-watcher/tree/1.2.0" - }, - "time": "2026-03-12T09:16:49+00:00" - }, - { - "name": "spatie/laravel-package-tools", - "version": "1.93.0", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/0d097bce95b2bf6802fb1d83e1e753b0f5a948e7", - "reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^10.0|^11.0|^12.0|^13.0", - "php": "^8.1" - }, - "require-dev": { - "mockery/mockery": "^1.5", - "orchestra/testbench": "^8.0|^9.2|^10.0|^11.0", - "pestphp/pest": "^2.1|^3.1|^4.0", - "phpunit/php-code-coverage": "^10.0|^11.0|^12.0", - "phpunit/phpunit": "^10.5|^11.5|^12.5", - "spatie/pest-plugin-test-time": "^2.2|^3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\LaravelPackageTools\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "role": "Developer" - } - ], - "description": "Tools for creating Laravel packages", - "homepage": "https://github.com/spatie/laravel-package-tools", - "keywords": [ - "laravel-package-tools", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.93.0" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2026-02-21T12:49:54+00:00" - }, { "name": "staabm/side-effects-detector", "version": "1.0.5", diff --git a/config/trypost.php b/config/trypost.php index c0606acd..ea202f01 100644 --- a/config/trypost.php +++ b/config/trypost.php @@ -16,6 +16,24 @@ 'self_hosted' => env('SELF_HOSTED', true), + /* + |-------------------------------------------------------------------------- + | Media Size Limits + |-------------------------------------------------------------------------- + | + | Per-type size caps in megabytes. Single source of truth — direct + | uploads (StoreAssetRequest, AssetController::storeChunked), URL + | fetches (MediaAttacher), and the MediaType enum all read from here. + | + */ + + 'media' => [ + 'max_size_mb' => [ + 'image' => (int) env('MEDIA_IMAGE_MAX_SIZE_MB', 10), + 'video' => (int) env('MEDIA_VIDEO_MAX_SIZE_MB', 1024), + ], + ], + /* |-------------------------------------------------------------------------- | Google Authentication diff --git a/docs/superpowers/plans/2026-04-14-workspace-billing-plans.md b/docs/superpowers/plans/2026-04-14-workspace-billing-plans.md deleted file mode 100644 index 24fff357..00000000 --- a/docs/superpowers/plans/2026-04-14-workspace-billing-plans.md +++ /dev/null @@ -1,2223 +0,0 @@ -# Workspace Billing, Plans & Brands — Implementation Plan - -> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. - -**Goal:** Move billing from User to Workspace, introduce tiered plans with limits, and add Brands for grouping social accounts. - -**Architecture:** Workspace becomes the Cashier Billable entity with a `plan_id` FK. Plans table stores limits (social accounts, members, brands, AI images/videos, data retention). Laravel Pennant features resolve plan limits per workspace. Brands group social accounts within a workspace. Policies enforce limits using Pennant. - -**Tech Stack:** Laravel 13, Cashier (Stripe), Pennant, Pest, Vue 3 + Inertia v3 - ---- - -### Task 1: Create Plans Migration and Model - -**Files:** -- Create: `database/migrations/2026_04_14_000001_create_plans_table.php` -- Create: `app/Models/Plan.php` -- Create: `app/Enums/Plan/Slug.php` - -- [ ] **Step 1: Create migration** - -Run: `php artisan make:migration create_plans_table --no-interaction` - -Replace contents with: - -```php -uuid('id')->primary(); - $table->string('slug')->unique(); - $table->string('name'); - $table->string('stripe_monthly_price_id')->nullable(); - $table->string('stripe_yearly_price_id')->nullable(); - $table->integer('monthly_price'); - $table->integer('yearly_price'); - $table->integer('social_account_limit'); - $table->integer('member_limit'); - $table->integer('brand_limit'); - $table->integer('ai_images_limit'); - $table->integer('ai_videos_limit'); - $table->integer('data_retention_days'); - $table->integer('sort')->default(0); - $table->boolean('is_archived')->default(false); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('plans'); - } -}; -``` - -- [ ] **Step 2: Create Slug enum** - -Create `app/Enums/Plan/Slug.php`: - -```php - 'Starter', - self::Plus => 'Plus', - self::Pro => 'Pro', - self::Max => 'Max', - }; - } -} -``` - -- [ ] **Step 3: Create Plan model** - -Create `app/Models/Plan.php`: - -```php - Slug::class, - 'monthly_price' => 'integer', - 'yearly_price' => 'integer', - 'social_account_limit' => 'integer', - 'member_limit' => 'integer', - 'brand_limit' => 'integer', - 'ai_images_limit' => 'integer', - 'ai_videos_limit' => 'integer', - 'data_retention_days' => 'integer', - 'sort' => 'integer', - 'is_archived' => 'boolean', - ]; - } - - public function scopeActive(Builder $query): Builder - { - return $query->where('is_archived', false); - } - - public function workspaces(): HasMany - { - return $this->hasMany(Workspace::class); - } - - public function formattedMonthlyPrice(): string - { - return '$' . number_format($this->monthly_price / 100, 0); - } - - public function formattedYearlyPrice(): string - { - return '$' . number_format($this->yearly_price / 100, 0); - } -} -``` - -- [ ] **Step 4: Add Plan to morph map** - -In `app/Providers/AppServiceProvider.php`, add to the `enforceMorphMap` array (inside `configureMorphMap` method): - -```php -'plan' => Plan::class, -``` - -And add the import at the top: - -```php -use App\Models\Plan; -``` - -- [ ] **Step 5: Run migration** - -Run: `php artisan migrate` -Expected: `plans` table created. - -- [ ] **Step 6: Commit** - -```bash -git add -A && git commit -m "feat: create plans table, model, and slug enum" -``` - ---- - -### Task 2: Create PlanSeeder - -**Files:** -- Create: `database/seeders/PlanSeeder.php` -- Modify: `database/seeders/DatabaseSeeder.php` -- Create: `tests/Feature/PlanSeederTest.php` - -- [ ] **Step 1: Write the failing test** - -Run: `php artisan make:test PlanSeederTest --pest --no-interaction` - -Replace contents with: - -```php -seed(\Database\Seeders\PlanSeeder::class); - - expect(Plan::count())->toBe(4); -}); - -test('plan seeder creates plans with correct limits', function () { - $this->seed(\Database\Seeders\PlanSeeder::class); - - $starter = Plan::where('slug', Slug::Starter)->first(); - expect($starter)->not->toBeNull() - ->and($starter->name)->toBe('Starter') - ->and($starter->monthly_price)->toBe(1900) - ->and($starter->yearly_price)->toBe(19000) - ->and($starter->social_account_limit)->toBe(5) - ->and($starter->member_limit)->toBe(1) - ->and($starter->brand_limit)->toBe(0) - ->and($starter->ai_images_limit)->toBe(50) - ->and($starter->ai_videos_limit)->toBe(10) - ->and($starter->data_retention_days)->toBe(30); - - $max = Plan::where('slug', Slug::Max)->first(); - expect($max)->not->toBeNull() - ->and($max->monthly_price)->toBe(9900) - ->and($max->social_account_limit)->toBe(100) - ->and($max->member_limit)->toBe(20) - ->and($max->brand_limit)->toBe(50) - ->and($max->data_retention_days)->toBe(730); -}); - -test('plan seeder is idempotent', function () { - $this->seed(\Database\Seeders\PlanSeeder::class); - $this->seed(\Database\Seeders\PlanSeeder::class); - - expect(Plan::count())->toBe(4); -}); - -test('plan active scope excludes archived plans', function () { - $this->seed(\Database\Seeders\PlanSeeder::class); - - Plan::where('slug', Slug::Starter)->update(['is_archived' => true]); - - expect(Plan::active()->count())->toBe(3); -}); -``` - -- [ ] **Step 2: Run tests to verify they fail** - -Run: `php artisan test --compact tests/Feature/PlanSeederTest.php` -Expected: FAIL (PlanSeeder class not found) - -- [ ] **Step 3: Create PlanSeeder** - -Create `database/seeders/PlanSeeder.php`: - -```php - 'starter', - 'name' => 'Starter', - 'stripe_monthly_price_id' => env('STRIPE_STARTER_MONTHLY'), - 'stripe_yearly_price_id' => env('STRIPE_STARTER_YEARLY'), - 'monthly_price' => 1900, - 'yearly_price' => 19000, - 'social_account_limit' => 5, - 'member_limit' => 1, - 'brand_limit' => 0, - 'ai_images_limit' => 50, - 'ai_videos_limit' => 10, - 'data_retention_days' => 30, - 'sort' => 1, - ], - [ - 'slug' => 'plus', - 'name' => 'Plus', - 'stripe_monthly_price_id' => env('STRIPE_PLUS_MONTHLY'), - 'stripe_yearly_price_id' => env('STRIPE_PLUS_YEARLY'), - 'monthly_price' => 2900, - 'yearly_price' => 29000, - 'social_account_limit' => 10, - 'member_limit' => 5, - 'brand_limit' => 5, - 'ai_images_limit' => 150, - 'ai_videos_limit' => 30, - 'data_retention_days' => 60, - 'sort' => 2, - ], - [ - 'slug' => 'pro', - 'name' => 'Pro', - 'stripe_monthly_price_id' => env('STRIPE_PRO_MONTHLY'), - 'stripe_yearly_price_id' => env('STRIPE_PRO_YEARLY'), - 'monthly_price' => 4900, - 'yearly_price' => 49000, - 'social_account_limit' => 30, - 'member_limit' => 15, - 'brand_limit' => 15, - 'ai_images_limit' => 500, - 'ai_videos_limit' => 100, - 'data_retention_days' => 90, - 'sort' => 3, - ], - [ - 'slug' => 'max', - 'name' => 'Max', - 'stripe_monthly_price_id' => env('STRIPE_MAX_MONTHLY'), - 'stripe_yearly_price_id' => env('STRIPE_MAX_YEARLY'), - 'monthly_price' => 9900, - 'yearly_price' => 99000, - 'social_account_limit' => 100, - 'member_limit' => 20, - 'brand_limit' => 50, - 'ai_images_limit' => 2000, - 'ai_videos_limit' => 500, - 'data_retention_days' => 730, - 'sort' => 4, - ], - ]; - - foreach ($plans as $plan) { - Plan::updateOrCreate( - ['slug' => $plan['slug']], - $plan, - ); - } - } -} -``` - -- [ ] **Step 4: Register in DatabaseSeeder** - -In `database/seeders/DatabaseSeeder.php`, add inside `run()`: - -```php -$this->call([ - PlanSeeder::class, -]); -``` - -- [ ] **Step 5: Run tests** - -Run: `php artisan test --compact tests/Feature/PlanSeederTest.php` -Expected: 4 passed - -- [ ] **Step 6: Run seeder** - -Run: `php artisan db:seed --class=PlanSeeder` - -- [ ] **Step 7: Commit** - -```bash -git add -A && git commit -m "feat: create PlanSeeder with 4 tiered plans" -``` - ---- - -### Task 3: Create Brands Migration, Model, and CRUD - -**Files:** -- Create: `database/migrations/2026_04_14_000002_create_brands_table.php` -- Create: `database/migration/2026_04_14_000003_add_brand_id_to_social_accounts_table.php` -- Create: `app/Models/Brand.php` -- Create: `app/Http/Controllers/App/BrandController.php` -- Create: `app/Http/Requests/App/Brand/StoreBrandRequest.php` -- Create: `app/Http/Requests/App/Brand/UpdateBrandRequest.php` -- Create: `app/Policies/BrandPolicy.php` -- Modify: `app/Models/Workspace.php` — add `brands()` relationship -- Modify: `app/Models/SocialAccount.php` — add `brand()` relationship -- Modify: `routes/app.php` — add brand routes -- Modify: `app/Providers/AppServiceProvider.php` — add Brand to morph map -- Create: `tests/Feature/BrandControllerTest.php` - -- [ ] **Step 1: Create brands migration** - -Run: `php artisan make:migration create_brands_table --no-interaction` - -Replace contents with: - -```php -uuid('id')->primary(); - $table->foreignUuid('workspace_id')->constrained()->cascadeOnDelete(); - $table->string('name'); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('brands'); - } -}; -``` - -- [ ] **Step 2: Create brand_id migration for social_accounts** - -Run: `php artisan make:migration add_brand_id_to_social_accounts_table --no-interaction` - -Replace contents with: - -```php -foreignUuid('brand_id')->nullable()->after('workspace_id')->constrained()->nullOnDelete(); - }); - } - - public function down(): void - { - Schema::table('social_accounts', function (Blueprint $table) { - $table->dropConstrainedForeignId('brand_id'); - }); - } -}; -``` - -- [ ] **Step 3: Create Brand model** - -Create `app/Models/Brand.php`: - -```php -belongsTo(Workspace::class); - } - - public function socialAccounts(): HasMany - { - return $this->hasMany(SocialAccount::class); - } -} -``` - -- [ ] **Step 4: Add relationships to Workspace and SocialAccount** - -In `app/Models/Workspace.php`, add method: - -```php -public function brands(): HasMany -{ - return $this->hasMany(Brand::class); -} -``` - -In `app/Models/SocialAccount.php`, add `brand_id` to fillable and add method: - -```php -public function brand(): BelongsTo -{ - return $this->belongsTo(Brand::class); -} -``` - -- [ ] **Step 5: Add Brand to morph map** - -In `app/Providers/AppServiceProvider.php`, add to `enforceMorphMap`: - -```php -'brand' => Brand::class, -``` - -And import `use App\Models\Brand;` - -- [ ] **Step 6: Create BrandPolicy** - -Run: `php artisan make:policy BrandPolicy --no-interaction` - -Replace contents with: - -```php -hasMember($user); - } - - public function create(User $user, Workspace $workspace): bool - { - if (! $this->canManage($user, $workspace)) { - return false; - } - - if (config('trypost.self_hosted')) { - return true; - } - - $limit = $workspace->plan?->brand_limit ?? 0; - - return $workspace->brands()->count() < $limit; - } - - public function update(User $user, Brand $brand): bool - { - return $this->canManage($user, $brand->workspace); - } - - public function delete(User $user, Brand $brand): bool - { - return $this->canManage($user, $brand->workspace); - } - - private function canManage(User $user, Workspace $workspace): bool - { - $member = $workspace->members()->where('user_id', $user->id)->first(); - - if (! $member) { - return false; - } - - return in_array(Role::tryFrom($member->pivot->role), [Role::Owner, Role::Admin]); - } -} -``` - -- [ ] **Step 7: Create Form Requests** - -Create `app/Http/Requests/App/Brand/StoreBrandRequest.php`: - -```php - ['required', 'string', 'max:255'], - ]; - } -} -``` - -Create `app/Http/Requests/App/Brand/UpdateBrandRequest.php`: - -```php - ['required', 'string', 'max:255'], - ]; - } -} -``` - -- [ ] **Step 8: Create BrandController** - -Create `app/Http/Controllers/App/BrandController.php`: - -```php -user()->currentWorkspace; - - $this->authorize('viewAny', [Brand::class, $workspace]); - - $brands = $workspace->brands() - ->withCount('socialAccounts') - ->orderBy('name') - ->get(); - - return Inertia::render('brands/Index', [ - 'brands' => $brands, - 'canCreate' => $request->user()->can('create', [Brand::class, $workspace]), - ]); - } - - public function store(StoreBrandRequest $request): RedirectResponse - { - $workspace = $request->user()->currentWorkspace; - - $this->authorize('create', [Brand::class, $workspace]); - - $workspace->brands()->create([ - 'name' => data_get($request->validated(), 'name'), - ]); - - return back(); - } - - public function update(UpdateBrandRequest $request, Brand $brand): RedirectResponse - { - $this->authorize('update', $brand); - - $brand->update([ - 'name' => data_get($request->validated(), 'name'), - ]); - - return back(); - } - - public function destroy(Request $request, Brand $brand): RedirectResponse - { - $this->authorize('delete', $brand); - - $brand->delete(); - - return back(); - } -} -``` - -- [ ] **Step 9: Add routes** - -In `routes/app.php`, inside the subscribed middleware group (after the Labels section, around line 164), add: - -```php -// Brands -Route::get('brands', [BrandController::class, 'index'])->name('app.brands.index'); -Route::post('brands', [BrandController::class, 'store'])->name('app.brands.store'); -Route::put('brands/{brand}', [BrandController::class, 'update'])->name('app.brands.update'); -Route::delete('brands/{brand}', [BrandController::class, 'destroy'])->name('app.brands.destroy'); -``` - -Add the import at the top: `use App\Http\Controllers\App\BrandController;` - -- [ ] **Step 10: Run migrations** - -Run: `php artisan migrate` - -- [ ] **Step 11: Write tests** - -Run: `php artisan make:test BrandControllerTest --pest --no-interaction` - -Replace contents with: - -```php - true]); - - $this->user = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]); - $this->user->update(['current_workspace_id' => $this->workspace->id]); - $this->workspace->members()->attach($this->user->id, ['role' => Role::Owner->value]); -}); - -test('can list brands', function () { - Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'Brand A']); - Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'Brand B']); - - $response = $this->actingAs($this->user)->get(route('app.brands.index')); - - $response->assertOk(); - $brands = $response->original->getData()['page']['props']['brands']; - expect($brands)->toHaveCount(2); -}); - -test('can create brand', function () { - $response = $this->actingAs($this->user) - ->post(route('app.brands.store'), ['name' => 'My Brand']); - - $response->assertRedirect(); - expect($this->workspace->brands()->count())->toBe(1) - ->and($this->workspace->brands()->first()->name)->toBe('My Brand'); -}); - -test('can update brand', function () { - $brand = Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'Old Name']); - - $response = $this->actingAs($this->user) - ->put(route('app.brands.update', $brand), ['name' => 'New Name']); - - $response->assertRedirect(); - expect($brand->fresh()->name)->toBe('New Name'); -}); - -test('can delete brand', function () { - $brand = Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'To Delete']); - - $response = $this->actingAs($this->user) - ->delete(route('app.brands.destroy', $brand)); - - $response->assertRedirect(); - expect(Brand::find($brand->id))->toBeNull(); -}); - -test('deleting brand nullifies social account brand_id', function () { - $brand = Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'Test Brand']); - - $account = SocialAccount::factory()->create([ - 'workspace_id' => $this->workspace->id, - 'brand_id' => $brand->id, - 'platform' => Platform::Instagram, - 'status' => AccountStatus::Connected, - ]); - - $this->actingAs($this->user)->delete(route('app.brands.destroy', $brand)); - - expect($account->fresh()->brand_id)->toBeNull(); -}); - -test('cannot create brand beyond plan limit', function () { - config(['trypost.self_hosted' => false]); - - $plan = Plan::create([ - 'slug' => 'starter', 'name' => 'Starter', - 'monthly_price' => 1900, 'yearly_price' => 19000, - 'social_account_limit' => 5, 'member_limit' => 1, - 'brand_limit' => 0, 'ai_images_limit' => 50, - 'ai_videos_limit' => 10, 'data_retention_days' => 30, - 'sort' => 1, - ]); - $this->workspace->update(['plan_id' => $plan->id]); - - $response = $this->actingAs($this->user) - ->post(route('app.brands.store'), ['name' => 'Should Fail']); - - $response->assertForbidden(); -}); - -test('cannot access brands from another workspace', function () { - $otherUser = User::factory()->create(['setup' => Setup::Completed]); - $otherWorkspace = Workspace::factory()->create(['user_id' => $otherUser->id]); - $otherUser->update(['current_workspace_id' => $otherWorkspace->id]); - $otherWorkspace->members()->attach($otherUser->id, ['role' => Role::Owner->value]); - - $brand = Brand::create(['workspace_id' => $this->workspace->id, 'name' => 'Not Yours']); - - $response = $this->actingAs($otherUser) - ->put(route('app.brands.update', $brand), ['name' => 'Hacked']); - - $response->assertForbidden(); -}); -``` - -- [ ] **Step 12: Run tests** - -Run: `php artisan test --compact tests/Feature/BrandControllerTest.php` -Expected: All passed - -- [ ] **Step 13: Run Pint** - -Run: `vendor/bin/pint --dirty --format agent` - -- [ ] **Step 14: Commit** - -```bash -git add -A && git commit -m "feat: create brands with CRUD, policy, and tests" -``` - ---- - -### Task 4: Move Billable from User to Workspace - -**Files:** -- Create: `database/migrations/2026_04_14_000004_add_billing_columns_to_workspaces_table.php` -- Create: `database/migrations/2026_04_14_000005_migrate_subscriptions_to_workspace.php` -- Create: `database/migrations/2026_04_14_000006_remove_billing_columns_from_users_table.php` -- Modify: `app/Models/Workspace.php` — add Billable trait, plan relationship, billing methods -- Modify: `app/Models/User.php` — remove Billable trait and billing methods -- Modify: `app/Models/Traits/HasWorkspace.php` — remove workspace quantity methods -- Modify: `app/Providers/AppServiceProvider.php` — set Cashier customer model to Workspace -- Modify: `app/Http/Middleware/App/EnsureSubscribed.php` — check workspace subscription -- Modify: `app/Http/Controllers/App/BillingController.php` — use workspace for billing -- Modify: `app/Http/Controllers/App/OnboardingController.php` — use workspace for checkout -- Modify: `app/Listeners/StripeEventListener.php` — find Workspace by stripe_id -- Modify: `config/cashier.php` — remove plans section -- Modify: `database/factories/WorkspaceFactory.php` — add plan_id -- Create: `tests/Feature/WorkspaceBillingTest.php` - -- [ ] **Step 1: Create migration to add billing columns to workspaces** - -Run: `php artisan make:migration add_billing_columns_to_workspaces_table --no-interaction` - -```php -foreignUuid('plan_id')->nullable()->after('timezone')->constrained()->nullOnDelete(); - $table->string('stripe_id')->nullable()->after('plan_id')->index(); - $table->string('pm_type')->nullable()->after('stripe_id'); - $table->string('pm_last_four')->nullable()->after('pm_type'); - $table->timestamp('trial_ends_at')->nullable()->after('pm_last_four'); - }); - } - - public function down(): void - { - Schema::table('workspaces', function (Blueprint $table) { - $table->dropConstrainedForeignId('plan_id'); - $table->dropIndex(['stripe_id']); - $table->dropColumn(['stripe_id', 'pm_type', 'pm_last_four', 'trial_ends_at']); - }); - } -}; -``` - -- [ ] **Step 2: Create migration to change subscriptions FK** - -Run: `php artisan make:migration migrate_subscriptions_to_workspace --no-interaction` - -```php -dropForeign(['user_id']); - $table->dropColumn('user_id'); - $table->foreignUuid('workspace_id')->after('id')->constrained()->cascadeOnDelete(); - }); - } - - public function down(): void - { - Schema::table('subscriptions', function (Blueprint $table) { - $table->dropForeign(['workspace_id']); - $table->dropColumn('workspace_id'); - $table->foreignUuid('user_id')->after('id')->constrained()->cascadeOnDelete(); - }); - } -}; -``` - -- [ ] **Step 3: Create migration to remove billing columns from users** - -Run: `php artisan make:migration remove_billing_columns_from_users_table --no-interaction` - -```php -dropIndex(['stripe_id']); - $table->dropColumn(['stripe_id', 'pm_type', 'pm_last_four', 'trial_ends_at']); - }); - } - - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->string('stripe_id')->nullable()->index(); - $table->string('pm_type')->nullable(); - $table->string('pm_last_four')->nullable(); - $table->timestamp('trial_ends_at')->nullable(); - }); - } -}; -``` - -- [ ] **Step 4: Update Workspace model** - -Replace `app/Models/Workspace.php` with: - -```php - */ - use Billable, HasFactory, HasMedia, HasUuids; - - public const SUBSCRIPTION_NAME = 'default'; - - protected $fillable = [ - 'user_id', - 'name', - 'timezone', - 'plan_id', - ]; - - protected $appends = ['has_logo', 'logo_url']; - - public function getHasLogoAttribute(): bool - { - return $this->getFirstMedia('logo') !== null; - } - - public function getLogoUrlAttribute(): ?string - { - return $this->getFirstMediaUrl('logo') ?: null; - } - - public function owner(): BelongsTo - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function plan(): BelongsTo - { - return $this->belongsTo(Plan::class); - } - - public function members(): BelongsToMany - { - return $this->belongsToMany(User::class) - ->withPivot('role') - ->withTimestamps(); - } - - public function socialAccounts(): HasMany - { - return $this->hasMany(SocialAccount::class); - } - - public function posts(): HasMany - { - return $this->hasMany(Post::class); - } - - public function invites(): HasMany - { - return $this->hasMany(WorkspaceInvite::class); - } - - public function hashtags(): HasMany - { - return $this->hasMany(WorkspaceHashtag::class); - } - - public function labels(): HasMany - { - return $this->hasMany(WorkspaceLabel::class); - } - - public function apiTokens(): HasMany - { - return $this->hasMany(ApiToken::class); - } - - public function brands(): HasMany - { - return $this->hasMany(Brand::class); - } - - public function hasMember(User $user): bool - { - return $this->user_id === $user->id || $this->members()->where('user_id', $user->id)->exists(); - } - - public function hasConnectedPlatform(string $platform): bool - { - return $this->socialAccounts()->where('platform', $platform)->exists(); - } - - public function getSocialAccount(string $platform): ?SocialAccount - { - return $this->socialAccounts()->where('platform', $platform)->first(); - } - - public function hasActiveSubscription(): bool - { - if (config('trypost.self_hosted')) { - return true; - } - - return $this->subscribed(self::SUBSCRIPTION_NAME); - } - - public function isOnTrial(): bool - { - $subscription = $this->subscription(self::SUBSCRIPTION_NAME); - - return $subscription?->onTrial() ?? false; - } - - public function stripeEmail(): string - { - return $this->owner?->email ?? ''; - } - - public function stripeName(): string - { - return $this->name; - } -} -``` - -- [ ] **Step 5: Update User model — remove Billable** - -In `app/Models/User.php`: - -1. Remove `use Laravel\Cashier\Billable;` import (line 20) -2. Remove `Billable` from the trait use line (line 25): change to `use HasFactory, HasMedia, HasUuids, HasWorkspace, Notifiable;` -3. Remove `SUBSCRIPTION_NAME` constant (line 27) -4. Remove `hasActiveSubscription()` method (lines 120-127) -5. Remove `hasEverSubscribed()` method (lines 132-135) - -- [ ] **Step 6: Simplify HasWorkspace trait** - -Replace `app/Models/Traits/HasWorkspace.php` — remove all quantity/billing methods, keep only workspace navigation: - -```php -belongsToMany(Workspace::class, 'user_workspace') - ->withPivot('role') - ->withTimestamps(); - } - - public function currentWorkspace(): BelongsTo - { - return $this->belongsTo(Workspace::class, 'current_workspace_id'); - } - - public function switchWorkspace(Workspace $workspace): void - { - $this->update(['current_workspace_id' => $workspace->id]); - } - - public function belongsToWorkspace(Workspace $workspace): bool - { - return $this->workspaces()->where('workspaces.id', $workspace->id)->exists(); - } - - public function ownedWorkspacesCount(): int - { - return $this->workspaces()->wherePivot('role', Role::Owner->value)->count(); - } -} -``` - -- [ ] **Step 7: Update AppServiceProvider — Cashier customer model** - -In `app/Providers/AppServiceProvider.php`, add after line 77 (`Cashier::useSubscriptionItemModel`): - -```php -Cashier::useCustomerModel(Workspace::class); -``` - -- [ ] **Step 8: Update EnsureSubscribed middleware** - -Replace `app/Http/Middleware/App/EnsureSubscribed.php`: - -```php -user(); - - if (! $user) { - return redirect()->route('login'); - } - - $workspace = $user->currentWorkspace; - - if ($workspace && $workspace->hasActiveSubscription()) { - return $next($request); - } - - return redirect()->route('app.subscribe'); - } -} -``` - -- [ ] **Step 9: Update BillingController** - -Replace `app/Http/Controllers/App/BillingController.php`: - -```php -user()->currentWorkspace; - - if ($workspace && $workspace->hasActiveSubscription()) { - return redirect()->route('app.billing.index'); - } - - return Inertia::render('billing/Subscribe', [ - 'plans' => Plan::active()->orderBy('sort')->get(), - 'trialDays' => config('cashier.trial_days'), - ]); - } - - public function checkout(Request $request, Plan $plan): SymfonyResponse - { - $workspace = $request->user()->currentWorkspace; - - $this->authorize('manageBilling', $workspace); - - $priceId = $request->input('interval', 'monthly') === 'yearly' - ? $plan->stripe_yearly_price_id - : $plan->stripe_monthly_price_id; - - abort_if(! $priceId, 422, 'Plan price not configured'); - - $workspace->createOrGetStripeCustomer([ - 'email' => $workspace->stripeEmail(), - 'name' => $workspace->stripeName(), - ]); - - $subscription = $workspace->newSubscription(Workspace::SUBSCRIPTION_NAME, $priceId) - ->allowPromotionCodes() - ->trialDays(config('cashier.trial_days')); - - $checkoutSession = $subscription->checkout([ - 'success_url' => route('app.billing.processing') . '?status=success', - 'cancel_url' => route('app.billing.processing') . '?status=cancelled', - ]); - - $workspace->update(['plan_id' => $plan->id]); - - return Inertia::location($checkoutSession->url); - } - - public function processing(Request $request): Response|RedirectResponse - { - $workspace = $request->user()->currentWorkspace; - $status = $request->query('status', 'processing'); - - if ($workspace && $workspace->subscribed(Workspace::SUBSCRIPTION_NAME)) { - return redirect()->route('app.calendar'); - } - - if (! in_array($status, ['processing', 'success', 'cancelled'])) { - $status = 'processing'; - } - - return Inertia::render('billing/Processing', [ - 'workspaceId' => $workspace?->id, - 'status' => $status, - ]); - } - - public function index(Request $request): Response|RedirectResponse - { - $workspace = $request->user()->currentWorkspace; - - $this->authorize('manageBilling', $workspace); - - $subscription = $workspace->subscription(Workspace::SUBSCRIPTION_NAME); - - return Inertia::render('billing/Index', [ - 'hasSubscription' => $workspace->subscribed(Workspace::SUBSCRIPTION_NAME), - 'onTrial' => $subscription?->onTrial() ?? false, - 'trialEndsAt' => $subscription?->trial_ends_at?->toFormattedDateString(), - 'subscription' => $subscription?->only([ - 'stripe_status', - 'ends_at', - ]), - 'plan' => $workspace->plan, - 'plans' => Plan::active()->orderBy('sort')->get(), - 'invoices' => $workspace->invoices()->map(fn ($invoice) => [ - 'id' => $invoice->id, - 'date' => $invoice->date()->toFormattedDateString(), - 'total' => $invoice->total(), - 'status' => $invoice->status, - 'invoice_pdf' => $invoice->invoice_pdf, - ]), - 'defaultPaymentMethod' => $workspace->defaultPaymentMethod()?->card?->only([ - 'brand', - 'last4', - 'exp_month', - 'exp_year', - ]), - ]); - } - - public function swap(Request $request, Plan $plan): RedirectResponse - { - $workspace = $request->user()->currentWorkspace; - - $this->authorize('manageBilling', $workspace); - - abort_unless($workspace->subscribed(Workspace::SUBSCRIPTION_NAME), 422, 'No active subscription'); - - $priceId = $request->input('interval', 'monthly') === 'yearly' - ? $plan->stripe_yearly_price_id - : $plan->stripe_monthly_price_id; - - abort_if(! $priceId, 422, 'Plan price not configured'); - - $workspace->subscription(Workspace::SUBSCRIPTION_NAME)->swap($priceId); - $workspace->update(['plan_id' => $plan->id]); - - return redirect()->route('app.billing.index'); - } - - public function portal(Request $request): RedirectResponse - { - $workspace = $request->user()->currentWorkspace; - - $this->authorize('manageBilling', $workspace); - - return $workspace->redirectToBillingPortal( - route('app.billing.index') - ); - } -} -``` - -- [ ] **Step 10: Update OnboardingController** - -In `app/Http/Controllers/App/OnboardingController.php`, update `storeConnect()` method (lines 76-106). Change from `$user->newSubscription(...)` to `$workspace->newSubscription(...)`: - -```php -public function storeConnect(Request $request): SymfonyResponse|RedirectResponse -{ - $user = $request->user(); - $workspace = $user->currentWorkspace; - - if (config('trypost.self_hosted')) { - $user->update([ - 'setup' => Setup::Completed, - ]); - - session()->flash('flash.banner', __('auth.flash.welcome')); - session()->flash('flash.bannerStyle', 'success'); - - return redirect()->route('app.calendar'); - } - - $user->update([ - 'setup' => Setup::Subscription, - ]); - - $defaultPlan = Plan::where('slug', PlanSlug::Starter)->first(); - - $workspace->createOrGetStripeCustomer([ - 'email' => $workspace->stripeEmail(), - 'name' => $workspace->stripeName(), - ]); - - $subscription = $workspace->newSubscription(Workspace::SUBSCRIPTION_NAME, $defaultPlan->stripe_monthly_price_id) - ->allowPromotionCodes() - ->trialDays(config('cashier.trial_days')); - - $checkoutSession = $subscription->checkout([ - 'success_url' => route('app.onboarding.complete') . '?session_id={CHECKOUT_SESSION_ID}', - 'cancel_url' => route('app.onboarding.connect'), - ]); - - $workspace->update(['plan_id' => $defaultPlan->id]); - - return Inertia::location($checkoutSession->url); -} -``` - -Add imports at the top: -```php -use App\Enums\Plan\Slug as PlanSlug; -use App\Models\Plan; -use App\Models\Workspace; -``` - -- [ ] **Step 11: Update StripeEventListener** - -Replace `app/Listeners/StripeEventListener.php`: - -```php -payload, 'type'); - $stripeCustomerId = data_get($event->payload, 'data.object.customer'); - - if (! $stripeCustomerId) { - return; - } - - $workspace = Workspace::where('stripe_id', $stripeCustomerId)->first(); - - if (! $workspace) { - return; - } - - match ($type) { - 'customer.subscription.created' => $this->handleSubscriptionCreated($workspace, $event->payload), - 'customer.subscription.updated' => $this->handleSubscriptionUpdated($workspace, $event->payload), - 'customer.subscription.deleted' => $this->handleSubscriptionDeleted($workspace, $event->payload), - default => null, - }; - } catch (\Exception $e) { - Log::error('Stripe webhook error: ' . $e->getMessage(), [ - 'exception' => $e, - 'payload' => $event->payload, - ]); - } - } - - protected function handleSubscriptionCreated(Workspace $workspace, array $payload): void - { - $owner = $workspace->owner; - - if ($owner && $owner->setup === Setup::Subscription) { - $owner->update(['setup' => Setup::Completed]); - } - - SubscriptionCreated::dispatch($workspace); - } - - protected function handleSubscriptionUpdated(Workspace $workspace, array $payload): void - { - // - } - - protected function handleSubscriptionDeleted(Workspace $workspace, array $payload): void - { - // - } -} -``` - -- [ ] **Step 12: Update SubscriptionCreated event** - -Check and update `app/Events/SubscriptionCreated.php` to accept Workspace instead of User. (If it broadcasts to the user, it should get the owner from the workspace.) - -- [ ] **Step 13: Update routes** - -In `routes/app.php`, update billing routes: - -Replace line 42: -```php -Route::post('billing/checkout/{plan}', [BillingController::class, 'checkout'])->name('app.billing.checkout'); -``` - -Inside the subscribed middleware group, add after the billing portal route (line 173): -```php -Route::post('settings/billing/swap/{plan}', [BillingController::class, 'swap'])->name('app.billing.swap'); -``` - -- [ ] **Step 14: Remove plans config from cashier.php** - -In `config/cashier.php`, remove the entire `plans` section (lines 129-163) and the `trial_days` section below it. Keep `trial_days` as a standalone config: - -Remove the `plans` array. Keep: -```php -'trial_days' => env('CASHIER_TRIAL_DAYS', 8), -``` - -- [ ] **Step 15: Update WorkspaceFactory** - -In `database/factories/WorkspaceFactory.php`, add `plan_id` to definition: - -```php -'plan_id' => null, -``` - -- [ ] **Step 16: Run migrations** - -Run: `php artisan migrate` - -- [ ] **Step 17: Write tests** - -Run: `php artisan make:test WorkspaceBillingTest --pest --no-interaction` - -Replace contents with: - -```php - true]); - - $this->user = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]); - $this->user->update(['current_workspace_id' => $this->workspace->id]); - $this->workspace->members()->attach($this->user->id, ['role' => Role::Owner->value]); -}); - -test('workspace has active subscription in self hosted mode', function () { - expect($this->workspace->hasActiveSubscription())->toBeTrue(); -}); - -test('workspace without subscription is not active in saas mode', function () { - config(['trypost.self_hosted' => false]); - - expect($this->workspace->hasActiveSubscription())->toBeFalse(); -}); - -test('workspace belongs to plan', function () { - $plan = Plan::create([ - 'slug' => 'starter', 'name' => 'Starter', - 'monthly_price' => 1900, 'yearly_price' => 19000, - 'social_account_limit' => 5, 'member_limit' => 1, - 'brand_limit' => 0, 'ai_images_limit' => 50, - 'ai_videos_limit' => 10, 'data_retention_days' => 30, - 'sort' => 1, - ]); - - $this->workspace->update(['plan_id' => $plan->id]); - - expect($this->workspace->fresh()->plan->name)->toBe('Starter'); -}); - -test('ensure subscribed middleware passes in self hosted mode', function () { - $response = $this->actingAs($this->user)->get(route('app.calendar')); - - $response->assertOk(); -}); - -test('ensure subscribed middleware redirects without subscription in saas mode', function () { - config(['trypost.self_hosted' => false]); - - $response = $this->actingAs($this->user)->get(route('app.calendar')); - - $response->assertRedirect(route('app.subscribe')); -}); - -test('billing page is accessible by workspace owner', function () { - $response = $this->actingAs($this->user)->get(route('app.billing.index')); - - $response->assertOk(); -}); - -test('billing page is not accessible by workspace member', function () { - $member = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace->members()->attach($member->id, ['role' => Role::Member->value]); - $member->update(['current_workspace_id' => $this->workspace->id]); - - $response = $this->actingAs($member)->get(route('app.billing.index')); - - $response->assertForbidden(); -}); - -test('subscribe page shows plans', function () { - config(['trypost.self_hosted' => false]); - - $this->seed(\Database\Seeders\PlanSeeder::class); - - $response = $this->actingAs($this->user)->get(route('app.subscribe')); - - $response->assertOk(); - $plans = $response->original->getData()['page']['props']['plans']; - expect($plans)->toHaveCount(4); -}); - -test('stripe email returns workspace owner email', function () { - expect($this->workspace->stripeEmail())->toBe($this->user->email); -}); - -test('stripe name returns workspace name', function () { - expect($this->workspace->stripeName())->toBe($this->workspace->name); -}); -``` - -- [ ] **Step 18: Run all tests** - -Run: `php artisan test --compact` -Expected: All passed (fix any failures from the billing migration) - -- [ ] **Step 19: Run Pint** - -Run: `vendor/bin/pint --dirty --format agent` - -- [ ] **Step 20: Commit** - -```bash -git add -A && git commit -m "feat: move Billable from User to Workspace with plan support" -``` - ---- - -### Task 5: Create Pennant Features - -**Files:** -- Create: `app/Features/SocialAccountLimit.php` -- Create: `app/Features/MemberLimit.php` -- Create: `app/Features/BrandLimit.php` -- Create: `app/Features/AiImagesLimit.php` -- Create: `app/Features/AiVideosLimit.php` -- Create: `app/Features/DataRetentionDays.php` -- Modify: `app/Providers/AppServiceProvider.php` — configure Pennant -- Create: `tests/Unit/Features/SocialAccountLimitTest.php` -- Create: `tests/Unit/Features/MemberLimitTest.php` -- Create: `tests/Unit/Features/BrandLimitTest.php` -- Create: `tests/Unit/Features/AiImagesLimitTest.php` -- Create: `tests/Unit/Features/AiVideosLimitTest.php` -- Create: `tests/Unit/Features/DataRetentionDaysTest.php` - -- [ ] **Step 1: Create feature classes** - -Create `app/Features/SocialAccountLimit.php`: - -```php -plan?->social_account_limit ?? 5; - } -} -``` - -Create `app/Features/MemberLimit.php`: - -```php -plan?->member_limit ?? 1; - } -} -``` - -Create `app/Features/BrandLimit.php`: - -```php -plan?->brand_limit ?? 0; - } -} -``` - -Create `app/Features/AiImagesLimit.php`: - -```php -plan?->ai_images_limit ?? 50; - } -} -``` - -Create `app/Features/AiVideosLimit.php`: - -```php -plan?->ai_videos_limit ?? 10; - } -} -``` - -Create `app/Features/DataRetentionDays.php`: - -```php -plan?->data_retention_days ?? 30; - } -} -``` - -- [ ] **Step 2: Configure Pennant in AppServiceProvider** - -In `app/Providers/AppServiceProvider.php`, add at the end of `boot()` method (after the Cashier lines): - -```php -Feature::resolveScopeUsing(fn () => auth()->user()?->currentWorkspace); -Feature::useMorphMap(); -Feature::discover(); -``` - -Add import at top: -```php -use Laravel\Pennant\Feature; -``` - -- [ ] **Step 3: Write unit tests** - -Create `tests/Unit/Features/SocialAccountLimitTest.php`: - -```php - 30]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new SocialAccountLimit)->resolve($workspace))->toBe(30); -}); - -test('falls back to 5 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new SocialAccountLimit)->resolve($workspace))->toBe(5); -}); -``` - -Create `tests/Unit/Features/MemberLimitTest.php`: - -```php - 15]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new MemberLimit)->resolve($workspace))->toBe(15); -}); - -test('falls back to 1 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new MemberLimit)->resolve($workspace))->toBe(1); -}); -``` - -Create `tests/Unit/Features/BrandLimitTest.php`: - -```php - 15]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new BrandLimit)->resolve($workspace))->toBe(15); -}); - -test('falls back to 0 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new BrandLimit)->resolve($workspace))->toBe(0); -}); -``` - -Create `tests/Unit/Features/AiImagesLimitTest.php`: - -```php - 500]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new AiImagesLimit)->resolve($workspace))->toBe(500); -}); - -test('falls back to 50 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new AiImagesLimit)->resolve($workspace))->toBe(50); -}); -``` - -Create `tests/Unit/Features/AiVideosLimitTest.php`: - -```php - 100]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new AiVideosLimit)->resolve($workspace))->toBe(100); -}); - -test('falls back to 10 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new AiVideosLimit)->resolve($workspace))->toBe(10); -}); -``` - -Create `tests/Unit/Features/DataRetentionDaysTest.php`: - -```php - 730]); - $workspace = new Workspace; - $workspace->setRelation('plan', $plan); - - expect((new DataRetentionDays)->resolve($workspace))->toBe(730); -}); - -test('falls back to 30 when no plan', function () { - $workspace = new Workspace; - $workspace->setRelation('plan', null); - - expect((new DataRetentionDays)->resolve($workspace))->toBe(30); -}); -``` - -- [ ] **Step 4: Run unit tests** - -Run: `php artisan test --compact tests/Unit/Features/` -Expected: 12 passed - -- [ ] **Step 5: Run Pint** - -Run: `vendor/bin/pint --dirty --format agent` - -- [ ] **Step 6: Commit** - -```bash -git add -A && git commit -m "feat: add Pennant features for plan limit resolution" -``` - ---- - -### Task 6: Update BrandPolicy to Use Pennant + Limit Enforcement on Social Accounts and Members - -**Files:** -- Modify: `app/Policies/BrandPolicy.php` — use Pennant -- Modify: `app/Policies/WorkspacePolicy.php` — add member limit check -- Create: `tests/Feature/LimitEnforcementTest.php` - -- [ ] **Step 1: Update BrandPolicy to use Pennant** - -Replace the `create` method in `app/Policies/BrandPolicy.php`: - -```php -use App\Features\BrandLimit; -use Laravel\Pennant\Feature; - -public function create(User $user, Workspace $workspace): bool -{ - if (! $this->canManage($user, $workspace)) { - return false; - } - - if (config('trypost.self_hosted')) { - return true; - } - - $limit = Feature::for($workspace)->value(BrandLimit::class); - - return $workspace->brands()->count() < $limit; -} -``` - -- [ ] **Step 2: Add member limit to WorkspacePolicy** - -In `app/Policies/WorkspacePolicy.php`, add method: - -```php -use App\Features\MemberLimit; -use Laravel\Pennant\Feature; - -public function inviteMember(User $user, Workspace $workspace): bool -{ - if (! $this->hasRole($user, $workspace, [Role::Owner, Role::Admin])) { - return false; - } - - if (config('trypost.self_hosted')) { - return true; - } - - $limit = Feature::for($workspace)->value(MemberLimit::class); - - return $workspace->members()->count() < $limit; -} -``` - -- [ ] **Step 3: Write limit enforcement tests** - -Run: `php artisan make:test LimitEnforcementTest --pest --no-interaction` - -Replace contents with: - -```php - false]); - - $this->plan = Plan::create([ - 'slug' => 'plus', 'name' => 'Plus', - 'monthly_price' => 2900, 'yearly_price' => 29000, - 'social_account_limit' => 10, 'member_limit' => 5, - 'brand_limit' => 5, 'ai_images_limit' => 150, - 'ai_videos_limit' => 30, 'data_retention_days' => 60, - 'sort' => 2, - ]); - - $this->user = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace = Workspace::factory()->create([ - 'user_id' => $this->user->id, - 'plan_id' => $this->plan->id, - ]); - $this->user->update(['current_workspace_id' => $this->workspace->id]); - $this->workspace->members()->attach($this->user->id, ['role' => Role::Owner->value]); -}); - -test('can create brand within limit', function () { - expect($this->user->can('create', [Brand::class, $this->workspace]))->toBeTrue(); -}); - -test('cannot create brand beyond limit', function () { - for ($i = 0; $i < 5; $i++) { - Brand::create(['workspace_id' => $this->workspace->id, 'name' => "Brand {$i}"]); - } - - expect($this->user->can('create', [Brand::class, $this->workspace]))->toBeFalse(); -}); - -test('can invite member within limit', function () { - expect($this->user->can('inviteMember', $this->workspace))->toBeTrue(); -}); - -test('cannot invite member beyond limit', function () { - for ($i = 0; $i < 4; $i++) { - $member = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace->members()->attach($member->id, ['role' => Role::Member->value]); - } - - // Owner (1) + 4 members = 5 = limit - expect($this->user->can('inviteMember', $this->workspace))->toBeFalse(); -}); - -test('self hosted mode bypasses brand limit', function () { - config(['trypost.self_hosted' => true]); - - for ($i = 0; $i < 10; $i++) { - Brand::create(['workspace_id' => $this->workspace->id, 'name' => "Brand {$i}"]); - } - - expect($this->user->can('create', [Brand::class, $this->workspace]))->toBeTrue(); -}); - -test('self hosted mode bypasses member limit', function () { - config(['trypost.self_hosted' => true]); - - for ($i = 0; $i < 10; $i++) { - $member = User::factory()->create(['setup' => Setup::Completed]); - $this->workspace->members()->attach($member->id, ['role' => Role::Member->value]); - } - - expect($this->user->can('inviteMember', $this->workspace))->toBeTrue(); -}); -``` - -- [ ] **Step 4: Run tests** - -Run: `php artisan test --compact tests/Feature/LimitEnforcementTest.php` -Expected: All passed - -- [ ] **Step 5: Run Pint** - -Run: `vendor/bin/pint --dirty --format agent` - -- [ ] **Step 6: Commit** - -```bash -git add -A && git commit -m "feat: enforce plan limits via Pennant in policies" -``` - ---- - -### Task 7: Run Full Test Suite and Fix Breakages - -- [ ] **Step 1: Run full test suite** - -Run: `php artisan test --compact` - -- [ ] **Step 2: Fix any failures caused by the billing migration** - -Common things to check: -- Tests that reference `User::SUBSCRIPTION_NAME` — change to `Workspace::SUBSCRIPTION_NAME` -- Tests that call `$user->subscribed()` — change to `$workspace->subscribed()` -- Tests that reference `$user->subscription()` — change to `$workspace->subscription()` -- Tests that use `$user->stripe_id` — the field no longer exists on User -- Middleware tests that check EnsureSubscribed — now checks workspace -- WorkspaceController tests that call `canCreateWorkspace` — method removed - -- [ ] **Step 3: Run Pint** - -Run: `vendor/bin/pint --dirty --format agent` - -- [ ] **Step 4: Run full test suite again** - -Run: `php artisan test --compact` -Expected: All passed - -- [ ] **Step 5: Commit** - -```bash -git add -A && git commit -m "fix: update existing tests for workspace billing migration" -``` diff --git a/docs/superpowers/specs/2026-04-14-workspace-billing-plans-design.md b/docs/superpowers/specs/2026-04-14-workspace-billing-plans-design.md deleted file mode 100644 index 7eb33c3c..00000000 --- a/docs/superpowers/specs/2026-04-14-workspace-billing-plans-design.md +++ /dev/null @@ -1,322 +0,0 @@ -# Account Billing, Plans & Workspaces - -## Overview - -Introduce an Account entity as the central billing and organizational unit. Account holds the Stripe subscription, plan, and limits. Workspaces group social accounts within an Account. Users belong to one Account with an account-level role (admin/user) and can be assigned to specific workspaces with workspace-level roles (member/viewer). The Account owner has full access to everything. - -## Data Model - -``` -Account (Billable, plan_id, owner_id) - ├── Users (account_id, account_role: admin/user) - └── Workspaces - ├── Members (user_id, workspace_role: member/viewer) - ├── Invites - └── Social Accounts -``` - -## Roles - -### Account-level - -Owner is determined by `accounts.owner_id`. No account-level role column on users. Only the owner can manage billing, create workspaces, and delete the account. The owner has full access to all workspaces automatically. - -### Workspace-level roles (`user_workspace.role`) - -| Role | Permissions | -|---|---| -| Admin | Everything in the workspace: manage members, connect accounts, settings | -| Member | Create posts, schedule | -| Viewer | View only (future: comments) | - -The Account owner has full access to all workspaces without needing a workspace pivot record. - -## Plans - -| Limit | Starter ($19/$190) | Plus ($29/$290) | Pro ($49/$490) | Max ($99/$990) | -|---|---|---|---|---| -| Social accounts | 5 | 10 | 30 | 100 | -| Members | 1 | 5 | 15 | 20 | -| Workspaces | 1 | 5 | 15 | 50 | -| AI Images/month | 50 | 150 | 500 | 2000 | -| AI Videos/month | 10 | 30 | 100 | 500 | -| Data retention (days) | 30 | 60 | 90 | 730 | -| Monthly price | $19 | $29 | $49 | $99 | -| Yearly price | $190 | $290 | $490 | $990 | - -All limits are at the **Account level** (totals across all workspaces). - -Starter plan: 1 member (owner only), 1 workspace (default, UI hides workspace management). - -Trial period: 8 days (configurable via `CASHIER_TRIAL_DAYS`). - ---- - -## Database Changes - -### New table: `accounts` - -| Column | Type | Notes | -|---|---|---| -| id | uuid, PK | | -| owner_id | FK -> users, nullable initially | Set after user creation (chicken-egg) | -| plan_id | FK -> plans, nullable | Current plan | -| name | string | Account/company name | -| stripe_id | string, nullable, indexed | Stripe customer ID | -| pm_type | string, nullable | Payment method type | -| pm_last_four | string, nullable | Last 4 digits | -| trial_ends_at | timestamp, nullable | | -| timestamps | | | - -Note: `owner_id` is nullable because during signup the user and account are created in the same transaction. Set `owner_id` after user creation. - -### New table: `plans` (unchanged from current) - -Already implemented. slug, name, stripe price IDs, all limits, sort, is_archived. - -### Modify table: `users` - -Add columns: -- `account_id` (FK -> accounts, nullable, constrained) -- `account_role` (string, default 'user') — enum: admin, user - -Remove columns: -- `stripe_id`, `pm_type`, `pm_last_four`, `trial_ends_at` (already removed) - -### Modify table: `workspaces` - -Remove columns: -- `plan_id` (moves to Account) -- `stripe_id`, `pm_type`, `pm_last_four`, `trial_ends_at` (moves to Account) - -Add columns: -- `account_id` (FK -> accounts, constrained, cascade delete) - -Keep: `user_id` (original creator, not necessarily the owner), `name`, `timezone` - -### Modify table: `user_workspace` - -Change `role` values from `owner/admin/member` to `member/viewer`. Owner is determined by Account, not workspace pivot. - -### Modify table: `subscriptions` - -Change FK from `workspace_id` to `account_id`. - -### Modify table: `invites` (rename from `workspace_invites`) - -| Column | Type | Notes | -|---|---|---| -| id | uuid, PK | | -| account_id | FK -> accounts, cascade delete | | -| email | string | Invited email | -| workspaces | json | Array of {workspace_id, role} | -| invited_by | FK -> users, nullable | Who sent the invite | -| accepted_at | timestamp, nullable | | -| timestamps | | | - -### Remove table: `brands` - -Brands concept is replaced by Workspaces. Remove brands table, remove `brand_id` from social_accounts. - ---- - -## Models - -### Account (new) - -- UUID primary key -- `Billable` trait from Cashier -- Constant: `SUBSCRIPTION_NAME = 'default'` -- Fillable: name, owner_id, plan_id -- Relationships: `owner()` belongsTo User, `plan()` belongsTo Plan, `users()` hasMany User, `workspaces()` hasMany Workspace, `invites()` hasMany Invite -- Methods: `hasActiveSubscription()`, `isOnTrial()`, `stripeEmail()` (owner email), `stripeName()` (account name) - -### User (modified) - -- Remove `Billable` trait (already removed) -- Add `account_id` and `account_role` to fillable -- Add cast: `account_role` to `AccountRole` enum -- Add relationship: `account()` belongsTo Account -- Remove: `HasWorkspace` trait methods related to billing -- Keep: `currentWorkspace()`, `switchWorkspace()`, workspace navigation methods -- Add: `isAccountOwner()` — `$this->id === $this->account?->owner_id` -- Add: `isAccountAdmin()` — `$this->account_role === AccountRole::Admin || $this->isAccountOwner()` - -### Workspace (modified) - -- Remove `Billable` trait -- Remove billing fields from fillable (stripe_id, pm_type, pm_last_four, trial_ends_at, plan_id) -- Add `account_id` to fillable -- Add relationship: `account()` belongsTo Account -- Keep: members(), socialAccounts(), posts(), invites is now on Account - -### Invite (modified from WorkspaceInvite) - -- Rename model from WorkspaceInvite to Invite -- Add: `account_id`, `workspaces` (json), `invited_by` -- Add cast: `workspaces` to array -- Relationship: `account()` belongsTo Account, `invitedBy()` belongsTo User - ---- - -## Enums - -### AccountRole (new) - -```php -enum AccountRole: string -{ - case Admin = 'admin'; - case User = 'user'; -} -``` - -### WorkspaceRole (modify existing) - -```php -enum WorkspaceRole: string -{ - case Member = 'member'; - case Viewer = 'viewer'; -} -``` - -Remove `Owner` and `Admin` cases. - ---- - -## Cashier Configuration - -### AppServiceProvider - -```php -Cashier::useCustomerModel(Account::class); -``` - ---- - -## Middleware: EnsureSubscribed - -1. If `config('trypost.self_hosted')` → pass -2. Get `$user->account` -3. If account has active subscription or trial → pass -4. Redirect to `/subscribe` - ---- - -## Pennant Features - -Scope changes from Workspace to Account: - -```php -Feature::resolveScopeUsing(fn () => auth()->user()?->account); -``` - -All 6 feature classes receive `Account $scope` instead of `Workspace $scope`: -- `SocialAccountLimit` — `$scope->plan?->social_account_limit ?? 5` -- `MemberLimit` — `$scope->plan?->member_limit ?? 1` -- `WorkspaceLimit` — `$scope->plan?->workspace_limit ?? 1` (replaces BrandLimit) -- `AiImagesLimit` — `$scope->plan?->ai_images_limit ?? 50` -- `AiVideosLimit` — `$scope->plan?->ai_videos_limit ?? 10` -- `DataRetentionDays` — `$scope->plan?->data_retention_days ?? 30` - ---- - -## Limit Enforcement - -All limits checked at Account level: - -- **Social accounts**: total across all workspaces in the account -- **Members**: unique users in the account (excluding owner) — `$account->users()->where('id', '!=', $account->owner_id)->count()` -- **Workspaces**: `$account->workspaces()->count()` -- **AI images/videos**: monthly usage tracked per account -- **Data retention**: applied per account - ---- - -## Controllers - -### BillingController - -All operations on `$user->account`: -- `$account->subscribed()`, `$account->subscription()`, `$account->invoices()` - -### OnboardingController - -Signup flow: -1. Create Account -2. Create User with `account_id` and `account_role = admin` (owner) -3. Set `account.owner_id` -4. Create default Workspace with `account_id` -5. Stripe checkout on Account - -### StripeEventListener - -Find `Account::where('stripe_id', $stripeCustomerId)` instead of Workspace. - -### InviteController (replaces WorkspaceInviteController) - -- `store()`: create invite on Account with workspaces + roles array -- On accept: set user's `account_id`, create workspace pivot records - ---- - -## Signup Flow - -1. User registers (name, email, password) -2. `CreateUser` action: - - Creates Account (name = user's name) - - Creates User with `account_id`, `account_role = admin` - - Sets `account.owner_id = user.id` - - Creates default Workspace within Account - - Sets `user.current_workspace_id` -3. Onboarding: role → connect accounts → Stripe checkout (on Account) - -## Invite Flow - -1. Owner/Admin creates invite: email + [{workspace_id, role}] -2. Email sent with invite link -3. Person clicks link: - - If no TryPost account: register with `account_id` pre-set, `account_role = user` - - If has TryPost account with same Account: add workspace assignments - - If has TryPost account with different Account: error — must use different email -4. Workspace pivot records created per the invite's workspaces array - ---- - -## UI Behavior by Plan - -### Starter (1 workspace, 1 member) -- Workspace switcher hidden -- "Create workspace" hidden -- Invite members hidden -- Simple single-workspace experience - -### Plus and above -- Workspace switcher visible -- Create workspace button visible -- Invite members visible -- Full multi-workspace experience - ---- - -## Plans table: workspace_limit replaces brand_limit - -| Column change | Old | New | -|---|---|---| -| brand_limit | 0, 5, 15, 50 | renamed to workspace_limit: 1, 5, 15, 50 | - ---- - -## Self-hosted mode - -All limits bypassed. Account still exists but no billing. Unlimited workspaces, members, social accounts. - ---- - -## What does NOT change - -- Social account OAuth flows (connect/disconnect) -- Post creation and publishing -- Analytics -- Multi-account social connections (multiple accounts per platform) diff --git a/docs/superpowers/specs/2026-04-23-instagram-facebook-variants-design.md b/docs/superpowers/specs/2026-04-23-instagram-facebook-variants-design.md deleted file mode 100644 index 673d60f5..00000000 --- a/docs/superpowers/specs/2026-04-23-instagram-facebook-variants-design.md +++ /dev/null @@ -1,288 +0,0 @@ -# Instagram and Facebook Content Variants in Post Editor - -**Date:** 2026-04-23 -**Branch:** feature/workspace-billing-plans - -## Problem - -The post editor has per-platform settings for TikTok (`TikTokSettings.vue`) but no equivalent UI for choosing content variants on Instagram (Feed / Reel / Story) and Facebook (Post / Reel / Story). The backend already supports these variants — `ContentType` enum maps to publisher branches in `InstagramPublisher` and `FacebookPublisher`, `UpdatePost` persists `content_type`, and `UpdatePostRequest` validates it — but `SyncPostPlatforms` always defaults to `InstagramFeed` / `FacebookPost` and the frontend has no way for users to change it. - -Users currently can only publish Feed posts on Instagram and standard Posts on Facebook, even when they want Reels or Stories. - -## Goals - -- Let users choose content variant per connected Instagram and Facebook account on the post edit page. -- Match the visual pattern established by `TikTokSettings.vue` (collapsible card with platform context). -- Support multiple connected accounts of the same platform (each card is independent — user can pick different variants for different accounts in the same post). -- Block submission with a clear warning when the chosen variant is incompatible with the attached media (mirrors existing `tiktokComplianceValid` pattern). -- Centralize media rules in a single source of truth, re-used for validation and for per-card warnings. - -## Non-Goals - -- Backend changes (publishers already handle all variants). -- Variant support for platforms beyond Instagram and Facebook (LinkedIn, Pinterest, etc. come later). -- Restricting the media upload picker based on variant — the variant-driven accept/max logic stays on the validation side, not on the file input (user can still drop any media; we just warn + block publish). - -## Design - -### New Files - -- `resources/js/components/posts/editor/InstagramSettings.vue` — rendered for `Platform::Instagram` and `Platform::InstagramFacebook` (same variant set). -- `resources/js/components/posts/editor/FacebookSettings.vue` — rendered for `Platform::Facebook`. -- `resources/js/composables/useMediaRules.ts` — restored from `main`, single source of truth for per-`content_type` media constraints. - -### Modified Files - -- `resources/js/pages/posts/Edit.vue` — add `platformContentTypes` state, compliance computeds, update `getSubmitData()` and autosave watcher, pipe new state into `ScheduleTab` and `PreviewTab`. -- `resources/js/components/posts/editor/ScheduleTab.vue` — accept `platformContentTypes` prop, emit `update:platform-content-type`, render `InstagramSettings` / `FacebookSettings` blocks per selected account. -- `resources/js/components/posts/editor/PreviewTab.vue` — read variant from `platformContentTypes[previewPlatform.id]` so preview updates live when user toggles variants. -- `lang/en/posts.php`, `lang/es/posts.php`, `lang/pt-BR/posts.php` — add translation keys for settings card, variant labels, warnings. - -### Component Structure (`InstagramSettings.vue`, `FacebookSettings.vue`) - -Mirror `TikTokSettings.vue`'s outer shell: - -- Collapsible root card with border. -- Header button: platform icon + `"Instagram settings"` / `"Facebook settings"` + chevron up/down. -- Closed by default; clicking the header toggles `open` ref. -- Body (when open): - - "Posting to" row: `Avatar` component + display name + `@username` of the connected account (critical when the user has multiple accounts of the same platform — makes clear which card configures which account). - - Variant picker: three horizontal pill buttons, one per variant. Active pill gets `bg-primary/10 border-primary`; inactive gets muted styling. Clicking emits `update:content-type` with the new value. - - Warning block (conditionally rendered): when `useMediaRules(contentType)` indicates the current `media` array violates the rules, render an `IconAlertTriangle` + short i18n message explaining the specific violation ("Reel requires a video", "Story accepts only 1 media", etc.). - -Props: - -```ts -interface Props { - socialAccount: SocialAccount | null; - contentType: string; // e.g. 'instagram_reel' - media: MediaItem[]; // to evaluate compliance warnings - disabled?: boolean; -} -``` - -Emits: - -```ts -'update:content-type': [value: string] -``` - -### Variant Catalog - -| Platform | Variants | Default | -|----------|----------|---------| -| Instagram (standalone + via Facebook) | `instagram_feed`, `instagram_reel`, `instagram_story` | `instagram_feed` | -| Facebook | `facebook_post`, `facebook_reel`, `facebook_story` | `facebook_post` | - -Labels and descriptions are already defined in `App\Enums\PostPlatform\ContentType` (`label()` and `description()` methods). Frontend uses i18n keys for display so strings stay in translation files, not in enum PHP strings. - -### State Management in `Edit.vue` - -Add a `platformContentTypes` ref that mirrors the existing `platformMeta` pattern exactly: - -```ts -const platformContentTypes = ref>( - Object.fromEntries( - post.value.post_platforms.map((pp) => [pp.id, pp.content_type ?? '']), - ), -); - -const updatePlatformContentType = (platformId: string, contentType: string) => { - platformContentTypes.value = { - ...platformContentTypes.value, - [platformId]: contentType, - }; -}; -``` - -This produces a dictionary keyed by `post_platform.id`, so two Instagram accounts get two independent entries. - -Update `getSubmitData()` to read `content_type` from state instead of the prop: - -```ts -const platforms = post.value.post_platforms - .filter((pp) => selectedPlatformIds.value.includes(pp.id)) - .map((pp) => ({ - id: pp.id, - content_type: platformContentTypes.value[pp.id] ?? pp.content_type, - meta: platformMeta.value[pp.id] ?? pp.meta ?? {}, - })); -``` - -Add `platformContentTypes` to the autosave `watch`: - -```ts -watch( - [content, media, selectedPlatformIds, scheduledDateTime, selectedLabelIds, platformMeta, platformContentTypes], - triggerAutosave, - { deep: true }, -); -``` - -### Media Rules Composable - -Restore `resources/js/composables/useMediaRules.ts` from `main` (the file already covered Instagram, Facebook, and every other platform correctly). The restored file keeps its original `useMediaRules(contentTypeRef)` reactive form (used inside settings components) and adds a small non-reactive helper for use in `Edit.vue`'s validation computeds: - -- `useMediaRules(contentTypeRef: Ref)` — reactive, already present on `main`, for use in `