Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanilla JS client library #408

Open
wants to merge 40 commits into
base: dev
Choose a base branch
from
Open

Vanilla JS client library #408

wants to merge 40 commits into from

Conversation

fomalhautb
Copy link
Contributor

@fomalhautb fomalhautb commented Jan 29, 2025


Important

Introduces a vanilla JavaScript client library for Stack with environment-specific code generation and updates to Docker and package management.

  • New Features:
    • Introduces a vanilla JavaScript client library in packages/js.
    • Adds example project in examples/js-example demonstrating usage of StackServerApp.
  • Docker:
    • Updates Dockerfile to include tsx and run generate-from-template.ts script.
  • Scripts:
    • Adds generate-from-template.ts for environment-specific code generation.
  • Package Management:
    • Updates package.json scripts to include template generation and environment checks.
  • Code Structure:
    • Moves shared code to packages/template and uses macros for environment-specific builds.
    • Removes email.tsx from packages/stack/src/utils.

This description was created by Ellipsis for 91c4f76. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jan 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 3:07am
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 3:07am
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 3:07am

Copy link

patched-codes bot commented Jan 29, 2025

Documentation Changes Required

  1. Overview Page (/docs/fern/docs/pages/sdk/overview.mdx)

    • Add StackAdminApp to the "Table of Contents" grid and link to its documentation section.
  2. Stack App Page (/docs/fern/docs/pages/sdk/objects/stack-app.mdx)

    • Add a new section after StackServerApp for StackAdminApp
    • Document that StackAdminApp inherits functionality from StackServerApp
    • Document admin-specific functionality like managing API keys, email templates, etc.
  3. User Types Page (/docs/fern/docs/pages/sdk/types/user.mdx)

    • Update the ServerUser and CurrentServerUser type definitions to reflect admin-specific functionality available when accessed via StackAdminApp
  4. Git Ignore File (packages/js/.gitignore)

    • Remove next-env.d.ts from being ignored
    • Add quetzal-translations directory to be ignored

Please ensure these changes are reflected in the relevant documentation files. All other changes analyzed do not require documentation updates as they are related to internal implementations, development tooling, or legal requirements that do not affect the public API or SDK functionality.

Copy link
Contributor

@N2D4 N2D4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good!

"build:packages": "only-allow pnpm && turbo run build --filter=./packages/*",
"clean": "only-allow pnpm && turbo run clean && rimraf --glob **/.next && rimraf --glob **/.turbo && rimraf .turbo && rimraf --glob **/node_modules",
"codegen": "only-allow pnpm && turbo run codegen",
"pre": "npx -y only-allow pnpm && node -e \"if(require('fs').existsSync('./scripts/generate-from-template.ts')) require('child_process').execSync('npx --package=ts-node ts-node ./scripts/generate-from-template.ts')\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we only do this if the file exists?

Copy link
Contributor Author

@fomalhautb fomalhautb Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used for the environment where all the code that is not linked to the entry file will be removed(for example in turbo docker build)

Comment on lines +2 to +9
"//": "IF_PLATFORM template",
"name": "@stackframe/template",
"//": "ELSE_IF_PLATFORM js",
"name": "@stackframe/js",
"//": "ELSE_IF_PLATFORM next",
"name": "@stackframe/stack",
"//": "END_PLATFORM",
"//": "NEXT_LINE_PLATFORM template",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need these if we commit the package.json anyways? (btw while duplicate keys are technically allowed by the JSON spec, we should probably avoid them if we can)

Copy link
Contributor Author

@fomalhautb fomalhautb Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the template to generate the package.json in template, js, and stack. It is very hard and requires a lot of tricks to make a valid package.json that is at the same time a valid template so I created a separate file for that

packages/template/src/lib/cookie.ts Outdated Show resolved Hide resolved
packages/template/src/lib/cookie.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants