From a66b81eeebb8c9aed23f93b4a6836a23050caf24 Mon Sep 17 00:00:00 2001 From: amitbardos Date: Sun, 4 Oct 2026 12:02:02 +0300 Subject: [PATCH] refactor: move to a monorepo with @base44/sdk in packages/sdk Move the SDK into packages/sdk and make the root a private npm workspaces root that holds the shared toolchain (devDependencies, tsconfig.base.json, ESLint). Publish and CI workflows build, version and publish from packages/sdk. No change to the published package. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/sdk-docs-writing/SKILL.md | 10 +- .github/workflows/claude-docs-drafter.yml | 14 +- .github/workflows/manual-publish.yml | 11 +- .github/workflows/preview-publish.yml | 7 +- .github/workflows/unit-tests.yml | 5 +- README.md | 151 +---------------- eslint.config.js | 5 +- package-lock.json | 30 ++-- package.json | 52 +----- packages/sdk/LICENSE | 21 +++ packages/sdk/README.md | 153 ++++++++++++++++++ .../sdk/examples}/basic-usage.js | 0 .../sdk/examples}/typescript-usage.ts | 0 packages/sdk/package.json | 49 ++++++ .../appended-articles.json | 0 .../category-map.json | 0 .../copy-to-local-docs.js | 2 +- .../file-processing/docs-json-template.json | 0 .../file-processing/file-processing.js | 0 .../file-processing/styling.css | 0 .../method-order.json | 0 .../typedoc-mintlify-content.js | 0 .../typedoc-mintlify-linked-types.js | 0 .../typedoc-mintlify-parameters.js | 0 .../typedoc-plugin/typedoc-mintlify-plugin.js | 0 .../typedoc-mintlify-returns.js | 0 .../typedoc-plugin/typedoc-mintlify-utils.js | 0 .../types-to-delete-after-processing.json | 0 .../types-to-expose.json | 0 {src => packages/sdk/src}/actor.ts | 0 {src => packages/sdk/src}/client.ts | 0 {src => packages/sdk/src}/client.types.ts | 0 {src => packages/sdk/src}/index.ts | 0 {src => packages/sdk/src}/modules/actors.ts | 0 .../sdk/src}/modules/actors.types.ts | 0 {src => packages/sdk/src}/modules/agents.ts | 0 .../sdk/src}/modules/agents.types.ts | 0 .../sdk/src}/modules/ai-gateway.ts | 0 .../sdk/src}/modules/ai-gateway.types.ts | 0 .../sdk/src}/modules/analytics.ts | 0 .../sdk/src}/modules/analytics.types.ts | 0 {src => packages/sdk/src}/modules/app-logs.ts | 0 .../sdk/src}/modules/app-logs.types.ts | 0 {src => packages/sdk/src}/modules/app.ts | 0 .../sdk/src}/modules/app.types.ts | 0 {src => packages/sdk/src}/modules/auth.ts | 0 .../sdk/src}/modules/auth.types.ts | 0 .../sdk/src}/modules/connectors.ts | 0 .../sdk/src}/modules/connectors.types.ts | 0 .../sdk/src}/modules/custom-integrations.ts | 0 .../src}/modules/custom-integrations.types.ts | 0 {src => packages/sdk/src}/modules/entities.ts | 0 .../sdk/src}/modules/entities.types.ts | 0 .../sdk/src}/modules/functions.ts | 0 .../sdk/src}/modules/functions.types.ts | 0 .../sdk/src}/modules/integrations.ts | 0 .../sdk/src}/modules/integrations.types.ts | 0 {src => packages/sdk/src}/modules/sso.ts | 0 .../sdk/src}/modules/sso.types.ts | 0 {src => packages/sdk/src}/modules/types.ts | 0 {src => packages/sdk/src}/modules/users.ts | 0 {src => packages/sdk/src}/types.ts | 0 {src => packages/sdk/src}/utils/auth-utils.ts | 0 .../sdk/src}/utils/auth-utils.types.ts | 0 .../sdk/src}/utils/axios-client.ts | 0 .../sdk/src}/utils/axios-client.types.ts | 0 {src => packages/sdk/src}/utils/common.ts | 0 .../sdk/src}/utils/fetch-with-auth.ts | 0 .../sdk/src}/utils/sharedInstance.ts | 0 .../sdk/src}/utils/socket-utils.ts | 0 {tests => packages/sdk/tests}/.env.example | 0 .../sdk/tests}/e2e/auth.test.js | 0 .../tests}/e2e/custom-integrations.test.js | 0 .../sdk/tests}/e2e/entities.test.js | 0 .../sdk/tests}/e2e/integrations.test.js | 0 {tests => packages/sdk/tests}/setup.js | 0 .../sdk/tests}/types/ai-gateway.types.ts | 0 .../sdk/tests}/types/connectors.types.ts | 0 .../sdk/tests}/types/entities-filter.types.ts | 0 .../tests}/types/entities-primitives.types.ts | 0 .../sdk/tests}/unit/actors.test.ts | 0 .../sdk/tests}/unit/agents.test.ts | 0 .../sdk/tests}/unit/ai-gateway.test.ts | 0 .../sdk/tests}/unit/analytics.test.ts | 0 .../unit/anonymous-visitor-header.test.ts | 0 .../sdk/tests}/unit/app.test.ts | 0 .../sdk/tests}/unit/auth.test.js | 0 .../sdk/tests}/unit/client.test.js | 0 .../sdk/tests}/unit/connectors-proxy.test.ts | 0 .../sdk/tests}/unit/connectors.test.ts | 0 .../tests}/unit/custom-integrations.test.ts | 0 .../tests}/unit/entities-primitives.test.ts | 0 .../tests}/unit/entities-subscribe.test.ts | 0 .../sdk/tests}/unit/entities.test.ts | 0 .../sdk/tests}/unit/fetch-with-auth.test.ts | 0 .../sdk/tests}/unit/functions.test.ts | 0 .../sdk/tests}/unit/integrations.test.js | 0 .../sdk/tests}/unit/integrations.test.ts | 0 .../sdk/tests}/unit/react-native.test.ts | 0 .../sdk/tests}/unit/socket-utils.test.ts | 0 .../sdk/tests}/unit/sso.test.ts | 0 .../sdk/tests}/unit/typedoc-returns.test.ts | 0 .../sdk/tests}/utils/circular-json-handler.js | 0 .../sdk/tests}/utils/test-config.js | 0 packages/sdk/tsconfig.json | 16 ++ .../sdk/tsconfig.type-tests.json | 0 typedoc.json => packages/sdk/typedoc.json | 0 .../sdk/vitest.config.ts | 0 .../sdk/writing-docs.md | 0 tsconfig.json => tsconfig.base.json | 12 +- 110 files changed, 316 insertions(+), 222 deletions(-) create mode 100644 packages/sdk/LICENSE create mode 100644 packages/sdk/README.md rename {examples => packages/sdk/examples}/basic-usage.js (100%) rename {examples => packages/sdk/examples}/typescript-usage.ts (100%) create mode 100644 packages/sdk/package.json rename {scripts => packages/sdk/scripts}/mintlify-post-processing/appended-articles.json (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/category-map.json (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/copy-to-local-docs.js (99%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/file-processing/docs-json-template.json (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/file-processing/file-processing.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/file-processing/styling.css (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/method-order.json (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-content.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-linked-types.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-parameters.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-plugin.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-returns.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-utils.js (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/types-to-delete-after-processing.json (100%) rename {scripts => packages/sdk/scripts}/mintlify-post-processing/types-to-expose.json (100%) rename {src => packages/sdk/src}/actor.ts (100%) rename {src => packages/sdk/src}/client.ts (100%) rename {src => packages/sdk/src}/client.types.ts (100%) rename {src => packages/sdk/src}/index.ts (100%) rename {src => packages/sdk/src}/modules/actors.ts (100%) rename {src => packages/sdk/src}/modules/actors.types.ts (100%) rename {src => packages/sdk/src}/modules/agents.ts (100%) rename {src => packages/sdk/src}/modules/agents.types.ts (100%) rename {src => packages/sdk/src}/modules/ai-gateway.ts (100%) rename {src => packages/sdk/src}/modules/ai-gateway.types.ts (100%) rename {src => packages/sdk/src}/modules/analytics.ts (100%) rename {src => packages/sdk/src}/modules/analytics.types.ts (100%) rename {src => packages/sdk/src}/modules/app-logs.ts (100%) rename {src => packages/sdk/src}/modules/app-logs.types.ts (100%) rename {src => packages/sdk/src}/modules/app.ts (100%) rename {src => packages/sdk/src}/modules/app.types.ts (100%) rename {src => packages/sdk/src}/modules/auth.ts (100%) rename {src => packages/sdk/src}/modules/auth.types.ts (100%) rename {src => packages/sdk/src}/modules/connectors.ts (100%) rename {src => packages/sdk/src}/modules/connectors.types.ts (100%) rename {src => packages/sdk/src}/modules/custom-integrations.ts (100%) rename {src => packages/sdk/src}/modules/custom-integrations.types.ts (100%) rename {src => packages/sdk/src}/modules/entities.ts (100%) rename {src => packages/sdk/src}/modules/entities.types.ts (100%) rename {src => packages/sdk/src}/modules/functions.ts (100%) rename {src => packages/sdk/src}/modules/functions.types.ts (100%) rename {src => packages/sdk/src}/modules/integrations.ts (100%) rename {src => packages/sdk/src}/modules/integrations.types.ts (100%) rename {src => packages/sdk/src}/modules/sso.ts (100%) rename {src => packages/sdk/src}/modules/sso.types.ts (100%) rename {src => packages/sdk/src}/modules/types.ts (100%) rename {src => packages/sdk/src}/modules/users.ts (100%) rename {src => packages/sdk/src}/types.ts (100%) rename {src => packages/sdk/src}/utils/auth-utils.ts (100%) rename {src => packages/sdk/src}/utils/auth-utils.types.ts (100%) rename {src => packages/sdk/src}/utils/axios-client.ts (100%) rename {src => packages/sdk/src}/utils/axios-client.types.ts (100%) rename {src => packages/sdk/src}/utils/common.ts (100%) rename {src => packages/sdk/src}/utils/fetch-with-auth.ts (100%) rename {src => packages/sdk/src}/utils/sharedInstance.ts (100%) rename {src => packages/sdk/src}/utils/socket-utils.ts (100%) rename {tests => packages/sdk/tests}/.env.example (100%) rename {tests => packages/sdk/tests}/e2e/auth.test.js (100%) rename {tests => packages/sdk/tests}/e2e/custom-integrations.test.js (100%) rename {tests => packages/sdk/tests}/e2e/entities.test.js (100%) rename {tests => packages/sdk/tests}/e2e/integrations.test.js (100%) rename {tests => packages/sdk/tests}/setup.js (100%) rename {tests => packages/sdk/tests}/types/ai-gateway.types.ts (100%) rename {tests => packages/sdk/tests}/types/connectors.types.ts (100%) rename {tests => packages/sdk/tests}/types/entities-filter.types.ts (100%) rename {tests => packages/sdk/tests}/types/entities-primitives.types.ts (100%) rename {tests => packages/sdk/tests}/unit/actors.test.ts (100%) rename {tests => packages/sdk/tests}/unit/agents.test.ts (100%) rename {tests => packages/sdk/tests}/unit/ai-gateway.test.ts (100%) rename {tests => packages/sdk/tests}/unit/analytics.test.ts (100%) rename {tests => packages/sdk/tests}/unit/anonymous-visitor-header.test.ts (100%) rename {tests => packages/sdk/tests}/unit/app.test.ts (100%) rename {tests => packages/sdk/tests}/unit/auth.test.js (100%) rename {tests => packages/sdk/tests}/unit/client.test.js (100%) rename {tests => packages/sdk/tests}/unit/connectors-proxy.test.ts (100%) rename {tests => packages/sdk/tests}/unit/connectors.test.ts (100%) rename {tests => packages/sdk/tests}/unit/custom-integrations.test.ts (100%) rename {tests => packages/sdk/tests}/unit/entities-primitives.test.ts (100%) rename {tests => packages/sdk/tests}/unit/entities-subscribe.test.ts (100%) rename {tests => packages/sdk/tests}/unit/entities.test.ts (100%) rename {tests => packages/sdk/tests}/unit/fetch-with-auth.test.ts (100%) rename {tests => packages/sdk/tests}/unit/functions.test.ts (100%) rename {tests => packages/sdk/tests}/unit/integrations.test.js (100%) rename {tests => packages/sdk/tests}/unit/integrations.test.ts (100%) rename {tests => packages/sdk/tests}/unit/react-native.test.ts (100%) rename {tests => packages/sdk/tests}/unit/socket-utils.test.ts (100%) rename {tests => packages/sdk/tests}/unit/sso.test.ts (100%) rename {tests => packages/sdk/tests}/unit/typedoc-returns.test.ts (100%) rename {tests => packages/sdk/tests}/utils/circular-json-handler.js (100%) rename {tests => packages/sdk/tests}/utils/test-config.js (100%) create mode 100644 packages/sdk/tsconfig.json rename tsconfig.type-tests.json => packages/sdk/tsconfig.type-tests.json (100%) rename typedoc.json => packages/sdk/typedoc.json (100%) rename vitest.config.ts => packages/sdk/vitest.config.ts (100%) rename writing-docs.md => packages/sdk/writing-docs.md (100%) rename tsconfig.json => tsconfig.base.json (66%) diff --git a/.claude/skills/sdk-docs-writing/SKILL.md b/.claude/skills/sdk-docs-writing/SKILL.md index ef1bfd94..667ed210 100644 --- a/.claude/skills/sdk-docs-writing/SKILL.md +++ b/.claude/skills/sdk-docs-writing/SKILL.md @@ -17,10 +17,10 @@ You write JSDoc. The tooling produces the final pages. | File pattern | Role | |---|---| -| `src/modules/*.types.ts` | **Public API surface** — JSDoc here becomes the published docs | -| `src/modules/*.ts` | Implementation — mark with `@internal` to hide from docs | -| `src/client.types.ts` | Client factory types | -| `src/types.ts` | Shared types | +| `packages/sdk/src/modules/*.types.ts` | **Public API surface** — JSDoc here becomes the published docs | +| `packages/sdk/src/modules/*.ts` | Implementation — mark with `@internal` to hide from docs | +| `packages/sdk/src/client.types.ts` | Client factory types | +| `packages/sdk/src/types.ts` | Shared types | Only types and functions **not** marked `@internal` appear in the generated docs. Implementation files should mark their exports `@internal`. @@ -93,4 +93,4 @@ Every public method needs: description, `@param` tags, `@returns`, and at least 2. **`@internal` on implementation:** Factory functions, config interfaces, and helpers are marked `@internal`. 3. **Examples work:** Code examples are syntactically valid TypeScript and use the `base44.` call path. 4. **Pipeline config:** New public types are in `types-to-expose.json`. Helper types that belong on another page are in `appended-articles.json`. -5. **Generate and review:** Run `npm run create-docs` and check the output renders correctly. +5. **Generate and review:** Run `npm run create-docs -w @base44/sdk` and check the output renders correctly. diff --git a/.github/workflows/claude-docs-drafter.yml b/.github/workflows/claude-docs-drafter.yml index 297cb90e..d37d4a74 100644 --- a/.github/workflows/claude-docs-drafter.yml +++ b/.github/workflows/claude-docs-drafter.yml @@ -4,9 +4,9 @@ on: pull_request: types: [opened, synchronize] paths: - - "src/modules/**" - - "src/client.types.ts" - - "src/types.ts" + - "packages/sdk/src/modules/**" + - "packages/sdk/src/client.types.ts" + - "packages/sdk/src/types.ts" jobs: claude-docs-draft: @@ -50,9 +50,9 @@ jobs: ## Your task 1. Read the documentation skill file at `.claude/skills/sdk-docs-writing/SKILL.md`. Follow its rules exactly. - 2. Look at the changes in this PR (the diff of files under `src/modules/`, `src/client.types.ts`, and `src/types.ts`). + 2. Look at the changes in this PR (the diff of files under `packages/sdk/src/modules/`, `packages/sdk/src/client.types.ts`, and `packages/sdk/src/types.ts`). 3. Identify any **new or modified public APIs** (interfaces, types, methods, properties) that are missing JSDoc or have incomplete JSDoc according to the skill's rules. - 4. Check the existing `.types.ts` files in `src/modules/` and the generated docs in `docs/content/` to understand the established patterns and voice. Your suggestions must match these patterns. + 4. Check the existing `.types.ts` files in `packages/sdk/src/modules/` and the generated docs in `packages/sdk/docs/content/` to understand the established patterns and voice. Your suggestions must match these patterns. ## How to report @@ -68,7 +68,7 @@ jobs: --- - #### `src/modules/example.types.ts` + #### `packages/sdk/src/modules/example.types.ts` **`ExampleModule.myMethod`** — *New method, missing JSDoc entirely.* @@ -125,7 +125,7 @@ jobs: - If a public API already has complete, correct JSDoc, skip it — don't suggest changes for the sake of it. - name: Add docs-draft label - if: success() && fromJSON(steps.claude-docs-drafter.outputs.structured_output).needs_docs == true + if: success() && fromJSON(steps.claude-docs-drafter.outputs.structured_output || '{}').needs_docs == true uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 with: script: | diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml index 7433ee5a..26e2c4a3 100644 --- a/.github/workflows/manual-publish.yml +++ b/.github/workflows/manual-publish.yml @@ -33,6 +33,8 @@ on: jobs: publish: runs-on: ubuntu-latest + env: + PACKAGE_DIR: packages/sdk permissions: # contents: write for the version-bump commit, tag, and GitHub Release. # id-token: write for npm trusted publishing (OIDC). @@ -72,7 +74,7 @@ jobs: run: npm ci - name: Build package - run: npm run build + run: npm run build -w ${{ env.PACKAGE_DIR }} - name: Check if version needs to be bumped id: check-version @@ -86,18 +88,21 @@ jobs: fi - name: Bump version + working-directory: ${{ env.PACKAGE_DIR }} if: steps.check-version.outputs.bump_version == 'true' run: | npm version ${{ steps.check-version.outputs.version_type }} --no-git-tag-version echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - name: Set version manually + working-directory: ${{ env.PACKAGE_DIR }} if: steps.check-version.outputs.bump_version == 'false' run: | npm version ${{ github.event.inputs.version }} --no-git-tag-version echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - name: Show package info + working-directory: ${{ env.PACKAGE_DIR }} run: | echo "Package name: $(node -p "require('./package.json').name")" echo "Version: ${{ env.NEW_VERSION }}" @@ -109,11 +114,13 @@ jobs: # the build. Needs a trusted publisher for `@base44/sdk` on npmjs.com # registered against this repo and this workflow filename — the registry # keys on the filename, so each publish workflow needs its own entry. + working-directory: ${{ env.PACKAGE_DIR }} if: github.event.inputs.dry_run == 'false' run: | npm publish --tag ${{ github.event.inputs.npm_tag }} - name: Dry run publish + working-directory: ${{ env.PACKAGE_DIR }} if: github.event.inputs.dry_run == 'true' run: | npm publish --dry-run --tag ${{ github.event.inputs.npm_tag }} @@ -123,7 +130,7 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add package.json package-lock.json + git add ${{ env.PACKAGE_DIR }}/package.json package-lock.json git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" git tag v${{ env.NEW_VERSION }} git push origin HEAD:${{ github.ref }} diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml index d88c6b4e..e905256e 100644 --- a/.github/workflows/preview-publish.yml +++ b/.github/workflows/preview-publish.yml @@ -45,9 +45,10 @@ jobs: run: npm ci - name: Build package - run: npm run build + run: npm run build -w @base44/sdk - name: Generate preview package name and version + working-directory: packages/sdk id: preview_info run: | PR_NUMBER="${{ github.event.number }}" @@ -70,6 +71,7 @@ jobs: echo "full_package=@base44-preview/sdk@$PREVIEW_VERSION" >> $GITHUB_OUTPUT - name: Update package.json for preview + working-directory: packages/sdk run: | # Create a backup of original package.json cp package.json package.json.bak @@ -103,6 +105,7 @@ jobs: echo "✅ Package.json updated successfully" - name: Final safety check before publish + working-directory: packages/sdk run: | # Double-check package name one more time before publishing CURRENT_PACKAGE_NAME=$(node -p "require('./package.json').name") @@ -119,6 +122,7 @@ jobs: echo "✅ Safety check passed. Package name is safe to publish." - name: Publish preview package + working-directory: packages/sdk # Authenticates via npm trusted publishing (OIDC), so no NPM_TOKEN reaches # the build. Needs a trusted publisher for `@base44-preview/sdk` on # npmjs.com registered against this repo and this workflow filename — the @@ -133,6 +137,7 @@ jobs: fi - name: Restore original package.json + working-directory: packages/sdk if: always() run: | if [ -f package.json.bak ]; then diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f27c76b9..2b3c9e60 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -27,7 +27,8 @@ jobs: run: npm ci - name: Run type tests - run: npm run test:types + run: npm run test:types -w @base44/sdk - name: Run unit tests - run: npm run test:unit + run: npm run test:unit -w @base44/sdk + diff --git a/README.md b/README.md index 741fe2e2..4b6251aa 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,18 @@ -# Base44 JavaScript SDK +# Base44 JavaScript SDKs -The Base44 SDK provides a JavaScript interface for building apps on the Base44 platform. +| Package | Directory | What it's for | +| :- | :- | :- | +| [`@base44/sdk`](https://www.npmjs.com/package/@base44/sdk) | [`packages/sdk`](packages/sdk) | Apps built on Base44: entities, functions, auth and integrations | -You can use it in two ways: - -- **Inside Base44 apps**: When Base44 generates your app, the SDK is already set up and ready to use. -- **External apps**: Use the SDK to build your own frontend or backend that uses Base44 as a backend service. - -## Installation - -**Inside Base44 apps**: The SDK is already available. No installation needed. - -**External apps**: Install the SDK via npm: - -```bash -npm install @base44/sdk -``` - -## Modules - -The SDK provides access to Base44's functionality through the following modules: - -- **[`agents`](https://docs.base44.com/developers/references/sdk/docs/interfaces/agents)**: Interact with AI agents and manage conversations. -- **[`analytics`](https://docs.base44.com/developers/references/sdk/docs/interfaces/analytics)**: Track custom events in your app. -- **[`app-logs`](https://docs.base44.com/developers/references/sdk/docs/interfaces/app-logs)**: Access and query app logs. -- **[`auth`](https://docs.base44.com/developers/references/sdk/docs/interfaces/auth)**: Manage user authentication, registration, and session handling. -- **[`connectors`](https://docs.base44.com/developers/references/sdk/docs/interfaces/connectors)**: Manage OAuth connections and access tokens for third-party services. -- **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations. -- **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions. -- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations. - -## Quickstarts - -How you get started depends on whether you're working inside a Base44-generated app or building your own. - -### Inside Base44 apps - -In Base44-generated apps, the client is pre-configured. Just import and use it: - -```typescript -import { base44 } from "@/api/base44Client"; - -// Create a new task -const newTask = await base44.entities.Task.create({ - title: "Complete project documentation", - status: "pending", - dueDate: "2024-12-31", -}); - -// Update the task -await base44.entities.Task.update(newTask.id, { - status: "in-progress", -}); - -// List all tasks -const tasks = await base44.entities.Task.list(); -``` - -### External apps - -When using Base44 as a backend for your own app, install the SDK and create the client yourself: - -```typescript -import { createClient } from "@base44/sdk"; - -// Create a client for your Base44 app -const base44 = createClient({ - appId: "your-app-id", // Find this in the Base44 editor URL -}); - -// Read public data -const products = await base44.entities.Products.list(); - -// Authenticate a user (token is automatically set) -await base44.auth.loginViaEmailPassword("user@example.com", "password"); - -// Access user's data -const userOrders = await base44.entities.Orders.list(); -``` - -### Service role - -By default, the client operates with user-level permissions, limiting access to what the current user can see and do. The service role provides elevated permissions for backend operations and is only available in Base44-hosted backend functions. External backends can't use service role permissions. - -```typescript -import { createClientFromRequest } from "npm:@base44/sdk"; - -Deno.serve(async (req) => { - const base44 = createClientFromRequest(req); - - // Access all data with admin-level permissions - const allOrders = await base44.asServiceRole.entities.Orders.list(); - - return Response.json({ orders: allOrders }); -}); -``` - -## Learn more - -The best way to get started with the JavaScript SDK is to have Base44 build an app for you. Once you have an app, you can explore the generated code and experiment with the SDK to see how it works in practice. You can also ask Base44 to demonstrate specific features of the SDK. - -For a deeper understanding, check out these guides: - -1. [Base44 client](https://docs.base44.com/developers/references/sdk/getting-started/client) - Work with the client in frontend, backend, and external app contexts. -2. [Work with data](https://docs.base44.com/developers/references/sdk/getting-started/work-with-data) - Create, read, update, and delete data. -3. [Common SDK patterns](https://docs.base44.com/developers/references/sdk/getting-started/work-with-sdk) - Authentication, integrations, functions, and error handling. - -For the complete documentation and API reference, visit the **[Base44 Developer Docs](https://docs.base44.com/developers/home)**. +Each package is versioned and released on its own through the **Manual Package Publish** workflow. ## Development -### Build the SDK - -Build the SDK from source: - ```bash -npm install +npm ci npm run build -``` - -### Run tests - -Run the test suite: - -```bash -# Run all tests +npm run lint npm test - -# Run unit tests only -npm run test:unit - -# Run with coverage -npm run test:coverage -``` - -For E2E tests, create a `tests/.env` file with: - ``` -BASE44_APP_ID=your_app_id -BASE44_AUTH_TOKEN=your_auth_token -``` - -### Generate documentation -Generate API documentation locally: - -```bash -# Process and preview locally -npm run create-docs -cd docs -mintlify dev -``` +Run a script in one package with `-w`, e.g. `npm run test:unit -w @base44/sdk`. diff --git a/eslint.config.js b/eslint.config.js index d7d5e1a0..595ecea0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,10 @@ import tsParser from "@typescript-eslint/parser"; export default [ { - files: ["src/**/*.ts"], + ignores: ["**/dist/**", "**/docs/**"], + }, + { + files: ["packages/*/src/**/*.ts"], languageOptions: { parser: tsParser, }, diff --git a/package-lock.json b/package-lock.json index c990d81f..1301bd3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,14 @@ { - "name": "@base44/sdk", + "name": "base44-javascript-sdk", "version": "0.8.52", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@base44/sdk", - "version": "0.8.52", - "license": "MIT", - "dependencies": { - "axios": "^1.20.0", - "partysocket": "^0.0.23", - "socket.io-client": "^4.8.3", - "uuid": "^13.0.2" - }, + "name": "base44-javascript-sdk", + "workspaces": [ + "packages/*" + ], "devDependencies": { "@types/hast": "^3.0.4", "@types/node": "^25.0.1", @@ -293,6 +288,10 @@ "node": ">=6.9.0" } }, + "node_modules/@base44/sdk": { + "resolved": "packages/sdk", + "link": true + }, "node_modules/@bcoe/v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", @@ -5871,6 +5870,17 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "packages/sdk": { + "name": "@base44/sdk", + "version": "0.8.52", + "license": "MIT", + "dependencies": { + "axios": "^1.20.0", + "partysocket": "^0.0.23", + "socket.io-client": "^4.8.3", + "uuid": "^13.0.2" + } } } } diff --git a/package.json b/package.json index 9c8c4620..802a87b0 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,14 @@ { - "name": "@base44/sdk", - "version": "0.8.52", - "description": "JavaScript SDK for Base44 API", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "name": "base44-javascript-sdk", + "private": true, "type": "module", - "files": [ - "dist" + "workspaces": [ + "packages/*" ], "scripts": { - "build": "tsc", - "lint": "eslint src", - "test": "npm run test:types && vitest run", - "test:types": "tsc --noEmit -p tsconfig.type-tests.json", - "test:unit": "vitest run tests/unit", - "test:e2e": "vitest run tests/e2e", - "test:watch": "vitest", - "test:coverage": "vitest run --coverage", - "docs": "typedoc", - "prepublishOnly": "npm run build", - "create-docs": "npm run create-docs:generate && npm run create-docs:process", - "create-docs-local": "npm run create-docs && npm run copy-docs-local", - "copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js", - "create-docs:generate": "typedoc", - "create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js" - }, - "dependencies": { - "axios": "^1.20.0", - "partysocket": "^0.0.23", - "socket.io-client": "^4.8.3", - "uuid": "^13.0.2" + "build": "npm run build --workspaces", + "lint": "eslint .", + "test": "npm test --workspaces" }, "devDependencies": { "@types/hast": "^3.0.4", @@ -48,20 +27,5 @@ "typescript": "^5.3.2", "typescript-eslint": "^8.51.0", "vitest": "^4.1.9" - }, - "keywords": [ - "base44", - "api", - "sdk" - ], - "author": "Base44", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/base44/javascript-sdk.git" - }, - "bugs": { - "url": "https://github.com/base44/javascript-sdk/issues" - }, - "homepage": "https://github.com/base44/javascript-sdk#readme" + } } diff --git a/packages/sdk/LICENSE b/packages/sdk/LICENSE new file mode 100644 index 00000000..648794e9 --- /dev/null +++ b/packages/sdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 base44 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/packages/sdk/README.md b/packages/sdk/README.md new file mode 100644 index 00000000..741fe2e2 --- /dev/null +++ b/packages/sdk/README.md @@ -0,0 +1,153 @@ +# Base44 JavaScript SDK + +The Base44 SDK provides a JavaScript interface for building apps on the Base44 platform. + +You can use it in two ways: + +- **Inside Base44 apps**: When Base44 generates your app, the SDK is already set up and ready to use. +- **External apps**: Use the SDK to build your own frontend or backend that uses Base44 as a backend service. + +## Installation + +**Inside Base44 apps**: The SDK is already available. No installation needed. + +**External apps**: Install the SDK via npm: + +```bash +npm install @base44/sdk +``` + +## Modules + +The SDK provides access to Base44's functionality through the following modules: + +- **[`agents`](https://docs.base44.com/developers/references/sdk/docs/interfaces/agents)**: Interact with AI agents and manage conversations. +- **[`analytics`](https://docs.base44.com/developers/references/sdk/docs/interfaces/analytics)**: Track custom events in your app. +- **[`app-logs`](https://docs.base44.com/developers/references/sdk/docs/interfaces/app-logs)**: Access and query app logs. +- **[`auth`](https://docs.base44.com/developers/references/sdk/docs/interfaces/auth)**: Manage user authentication, registration, and session handling. +- **[`connectors`](https://docs.base44.com/developers/references/sdk/docs/interfaces/connectors)**: Manage OAuth connections and access tokens for third-party services. +- **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations. +- **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions. +- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations. + +## Quickstarts + +How you get started depends on whether you're working inside a Base44-generated app or building your own. + +### Inside Base44 apps + +In Base44-generated apps, the client is pre-configured. Just import and use it: + +```typescript +import { base44 } from "@/api/base44Client"; + +// Create a new task +const newTask = await base44.entities.Task.create({ + title: "Complete project documentation", + status: "pending", + dueDate: "2024-12-31", +}); + +// Update the task +await base44.entities.Task.update(newTask.id, { + status: "in-progress", +}); + +// List all tasks +const tasks = await base44.entities.Task.list(); +``` + +### External apps + +When using Base44 as a backend for your own app, install the SDK and create the client yourself: + +```typescript +import { createClient } from "@base44/sdk"; + +// Create a client for your Base44 app +const base44 = createClient({ + appId: "your-app-id", // Find this in the Base44 editor URL +}); + +// Read public data +const products = await base44.entities.Products.list(); + +// Authenticate a user (token is automatically set) +await base44.auth.loginViaEmailPassword("user@example.com", "password"); + +// Access user's data +const userOrders = await base44.entities.Orders.list(); +``` + +### Service role + +By default, the client operates with user-level permissions, limiting access to what the current user can see and do. The service role provides elevated permissions for backend operations and is only available in Base44-hosted backend functions. External backends can't use service role permissions. + +```typescript +import { createClientFromRequest } from "npm:@base44/sdk"; + +Deno.serve(async (req) => { + const base44 = createClientFromRequest(req); + + // Access all data with admin-level permissions + const allOrders = await base44.asServiceRole.entities.Orders.list(); + + return Response.json({ orders: allOrders }); +}); +``` + +## Learn more + +The best way to get started with the JavaScript SDK is to have Base44 build an app for you. Once you have an app, you can explore the generated code and experiment with the SDK to see how it works in practice. You can also ask Base44 to demonstrate specific features of the SDK. + +For a deeper understanding, check out these guides: + +1. [Base44 client](https://docs.base44.com/developers/references/sdk/getting-started/client) - Work with the client in frontend, backend, and external app contexts. +2. [Work with data](https://docs.base44.com/developers/references/sdk/getting-started/work-with-data) - Create, read, update, and delete data. +3. [Common SDK patterns](https://docs.base44.com/developers/references/sdk/getting-started/work-with-sdk) - Authentication, integrations, functions, and error handling. + +For the complete documentation and API reference, visit the **[Base44 Developer Docs](https://docs.base44.com/developers/home)**. + +## Development + +### Build the SDK + +Build the SDK from source: + +```bash +npm install +npm run build +``` + +### Run tests + +Run the test suite: + +```bash +# Run all tests +npm test + +# Run unit tests only +npm run test:unit + +# Run with coverage +npm run test:coverage +``` + +For E2E tests, create a `tests/.env` file with: + +``` +BASE44_APP_ID=your_app_id +BASE44_AUTH_TOKEN=your_auth_token +``` + +### Generate documentation + +Generate API documentation locally: + +```bash +# Process and preview locally +npm run create-docs +cd docs +mintlify dev +``` diff --git a/examples/basic-usage.js b/packages/sdk/examples/basic-usage.js similarity index 100% rename from examples/basic-usage.js rename to packages/sdk/examples/basic-usage.js diff --git a/examples/typescript-usage.ts b/packages/sdk/examples/typescript-usage.ts similarity index 100% rename from examples/typescript-usage.ts rename to packages/sdk/examples/typescript-usage.ts diff --git a/packages/sdk/package.json b/packages/sdk/package.json new file mode 100644 index 00000000..91ab83d6 --- /dev/null +++ b/packages/sdk/package.json @@ -0,0 +1,49 @@ +{ + "name": "@base44/sdk", + "version": "0.8.52", + "description": "JavaScript SDK for Base44 API", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "type": "module", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc", + "test": "npm run test:types && vitest run", + "test:types": "tsc --noEmit -p tsconfig.type-tests.json", + "test:unit": "vitest run tests/unit", + "test:e2e": "vitest run tests/e2e", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage", + "docs": "typedoc", + "prepublishOnly": "npm run build", + "create-docs": "npm run create-docs:generate && npm run create-docs:process", + "create-docs-local": "npm run create-docs && npm run copy-docs-local", + "copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js", + "create-docs:generate": "typedoc", + "create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js" + }, + "dependencies": { + "axios": "^1.20.0", + "partysocket": "^0.0.23", + "socket.io-client": "^4.8.3", + "uuid": "^13.0.2" + }, + "keywords": [ + "base44", + "api", + "sdk" + ], + "author": "Base44", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/base44/javascript-sdk.git", + "directory": "packages/sdk" + }, + "bugs": { + "url": "https://github.com/base44/javascript-sdk/issues" + }, + "homepage": "https://github.com/base44/javascript-sdk/tree/main/packages/sdk#readme" +} diff --git a/scripts/mintlify-post-processing/appended-articles.json b/packages/sdk/scripts/mintlify-post-processing/appended-articles.json similarity index 100% rename from scripts/mintlify-post-processing/appended-articles.json rename to packages/sdk/scripts/mintlify-post-processing/appended-articles.json diff --git a/scripts/mintlify-post-processing/category-map.json b/packages/sdk/scripts/mintlify-post-processing/category-map.json similarity index 100% rename from scripts/mintlify-post-processing/category-map.json rename to packages/sdk/scripts/mintlify-post-processing/category-map.json diff --git a/scripts/mintlify-post-processing/copy-to-local-docs.js b/packages/sdk/scripts/mintlify-post-processing/copy-to-local-docs.js similarity index 99% rename from scripts/mintlify-post-processing/copy-to-local-docs.js rename to packages/sdk/scripts/mintlify-post-processing/copy-to-local-docs.js index 5d68a64b..9dbebdbf 100644 --- a/scripts/mintlify-post-processing/copy-to-local-docs.js +++ b/packages/sdk/scripts/mintlify-post-processing/copy-to-local-docs.js @@ -27,7 +27,7 @@ const CATEGORY_MAP_PATH = path.join(import.meta.dirname, "./category-map.json"); // Default: assume mintlify-docs is a sibling directory to javascript-sdk const SDK_ROOT = path.join(import.meta.dirname, "../.."); -const DEFAULT_TARGET = path.join(SDK_ROOT, "../mintlify-docs"); +const DEFAULT_TARGET = path.join(SDK_ROOT, "../../../mintlify-docs"); function parseArgs() { const args = process.argv.slice(2); diff --git a/scripts/mintlify-post-processing/file-processing/docs-json-template.json b/packages/sdk/scripts/mintlify-post-processing/file-processing/docs-json-template.json similarity index 100% rename from scripts/mintlify-post-processing/file-processing/docs-json-template.json rename to packages/sdk/scripts/mintlify-post-processing/file-processing/docs-json-template.json diff --git a/scripts/mintlify-post-processing/file-processing/file-processing.js b/packages/sdk/scripts/mintlify-post-processing/file-processing/file-processing.js similarity index 100% rename from scripts/mintlify-post-processing/file-processing/file-processing.js rename to packages/sdk/scripts/mintlify-post-processing/file-processing/file-processing.js diff --git a/scripts/mintlify-post-processing/file-processing/styling.css b/packages/sdk/scripts/mintlify-post-processing/file-processing/styling.css similarity index 100% rename from scripts/mintlify-post-processing/file-processing/styling.css rename to packages/sdk/scripts/mintlify-post-processing/file-processing/styling.css diff --git a/scripts/mintlify-post-processing/method-order.json b/packages/sdk/scripts/mintlify-post-processing/method-order.json similarity index 100% rename from scripts/mintlify-post-processing/method-order.json rename to packages/sdk/scripts/mintlify-post-processing/method-order.json diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-content.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-content.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-content.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-content.js diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-linked-types.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-linked-types.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-linked-types.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-linked-types.js diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-parameters.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-parameters.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-parameters.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-parameters.js diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-plugin.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-plugin.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-plugin.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-plugin.js diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-returns.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-returns.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-returns.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-returns.js diff --git a/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-utils.js b/packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-utils.js similarity index 100% rename from scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-utils.js rename to packages/sdk/scripts/mintlify-post-processing/typedoc-plugin/typedoc-mintlify-utils.js diff --git a/scripts/mintlify-post-processing/types-to-delete-after-processing.json b/packages/sdk/scripts/mintlify-post-processing/types-to-delete-after-processing.json similarity index 100% rename from scripts/mintlify-post-processing/types-to-delete-after-processing.json rename to packages/sdk/scripts/mintlify-post-processing/types-to-delete-after-processing.json diff --git a/scripts/mintlify-post-processing/types-to-expose.json b/packages/sdk/scripts/mintlify-post-processing/types-to-expose.json similarity index 100% rename from scripts/mintlify-post-processing/types-to-expose.json rename to packages/sdk/scripts/mintlify-post-processing/types-to-expose.json diff --git a/src/actor.ts b/packages/sdk/src/actor.ts similarity index 100% rename from src/actor.ts rename to packages/sdk/src/actor.ts diff --git a/src/client.ts b/packages/sdk/src/client.ts similarity index 100% rename from src/client.ts rename to packages/sdk/src/client.ts diff --git a/src/client.types.ts b/packages/sdk/src/client.types.ts similarity index 100% rename from src/client.types.ts rename to packages/sdk/src/client.types.ts diff --git a/src/index.ts b/packages/sdk/src/index.ts similarity index 100% rename from src/index.ts rename to packages/sdk/src/index.ts diff --git a/src/modules/actors.ts b/packages/sdk/src/modules/actors.ts similarity index 100% rename from src/modules/actors.ts rename to packages/sdk/src/modules/actors.ts diff --git a/src/modules/actors.types.ts b/packages/sdk/src/modules/actors.types.ts similarity index 100% rename from src/modules/actors.types.ts rename to packages/sdk/src/modules/actors.types.ts diff --git a/src/modules/agents.ts b/packages/sdk/src/modules/agents.ts similarity index 100% rename from src/modules/agents.ts rename to packages/sdk/src/modules/agents.ts diff --git a/src/modules/agents.types.ts b/packages/sdk/src/modules/agents.types.ts similarity index 100% rename from src/modules/agents.types.ts rename to packages/sdk/src/modules/agents.types.ts diff --git a/src/modules/ai-gateway.ts b/packages/sdk/src/modules/ai-gateway.ts similarity index 100% rename from src/modules/ai-gateway.ts rename to packages/sdk/src/modules/ai-gateway.ts diff --git a/src/modules/ai-gateway.types.ts b/packages/sdk/src/modules/ai-gateway.types.ts similarity index 100% rename from src/modules/ai-gateway.types.ts rename to packages/sdk/src/modules/ai-gateway.types.ts diff --git a/src/modules/analytics.ts b/packages/sdk/src/modules/analytics.ts similarity index 100% rename from src/modules/analytics.ts rename to packages/sdk/src/modules/analytics.ts diff --git a/src/modules/analytics.types.ts b/packages/sdk/src/modules/analytics.types.ts similarity index 100% rename from src/modules/analytics.types.ts rename to packages/sdk/src/modules/analytics.types.ts diff --git a/src/modules/app-logs.ts b/packages/sdk/src/modules/app-logs.ts similarity index 100% rename from src/modules/app-logs.ts rename to packages/sdk/src/modules/app-logs.ts diff --git a/src/modules/app-logs.types.ts b/packages/sdk/src/modules/app-logs.types.ts similarity index 100% rename from src/modules/app-logs.types.ts rename to packages/sdk/src/modules/app-logs.types.ts diff --git a/src/modules/app.ts b/packages/sdk/src/modules/app.ts similarity index 100% rename from src/modules/app.ts rename to packages/sdk/src/modules/app.ts diff --git a/src/modules/app.types.ts b/packages/sdk/src/modules/app.types.ts similarity index 100% rename from src/modules/app.types.ts rename to packages/sdk/src/modules/app.types.ts diff --git a/src/modules/auth.ts b/packages/sdk/src/modules/auth.ts similarity index 100% rename from src/modules/auth.ts rename to packages/sdk/src/modules/auth.ts diff --git a/src/modules/auth.types.ts b/packages/sdk/src/modules/auth.types.ts similarity index 100% rename from src/modules/auth.types.ts rename to packages/sdk/src/modules/auth.types.ts diff --git a/src/modules/connectors.ts b/packages/sdk/src/modules/connectors.ts similarity index 100% rename from src/modules/connectors.ts rename to packages/sdk/src/modules/connectors.ts diff --git a/src/modules/connectors.types.ts b/packages/sdk/src/modules/connectors.types.ts similarity index 100% rename from src/modules/connectors.types.ts rename to packages/sdk/src/modules/connectors.types.ts diff --git a/src/modules/custom-integrations.ts b/packages/sdk/src/modules/custom-integrations.ts similarity index 100% rename from src/modules/custom-integrations.ts rename to packages/sdk/src/modules/custom-integrations.ts diff --git a/src/modules/custom-integrations.types.ts b/packages/sdk/src/modules/custom-integrations.types.ts similarity index 100% rename from src/modules/custom-integrations.types.ts rename to packages/sdk/src/modules/custom-integrations.types.ts diff --git a/src/modules/entities.ts b/packages/sdk/src/modules/entities.ts similarity index 100% rename from src/modules/entities.ts rename to packages/sdk/src/modules/entities.ts diff --git a/src/modules/entities.types.ts b/packages/sdk/src/modules/entities.types.ts similarity index 100% rename from src/modules/entities.types.ts rename to packages/sdk/src/modules/entities.types.ts diff --git a/src/modules/functions.ts b/packages/sdk/src/modules/functions.ts similarity index 100% rename from src/modules/functions.ts rename to packages/sdk/src/modules/functions.ts diff --git a/src/modules/functions.types.ts b/packages/sdk/src/modules/functions.types.ts similarity index 100% rename from src/modules/functions.types.ts rename to packages/sdk/src/modules/functions.types.ts diff --git a/src/modules/integrations.ts b/packages/sdk/src/modules/integrations.ts similarity index 100% rename from src/modules/integrations.ts rename to packages/sdk/src/modules/integrations.ts diff --git a/src/modules/integrations.types.ts b/packages/sdk/src/modules/integrations.types.ts similarity index 100% rename from src/modules/integrations.types.ts rename to packages/sdk/src/modules/integrations.types.ts diff --git a/src/modules/sso.ts b/packages/sdk/src/modules/sso.ts similarity index 100% rename from src/modules/sso.ts rename to packages/sdk/src/modules/sso.ts diff --git a/src/modules/sso.types.ts b/packages/sdk/src/modules/sso.types.ts similarity index 100% rename from src/modules/sso.types.ts rename to packages/sdk/src/modules/sso.types.ts diff --git a/src/modules/types.ts b/packages/sdk/src/modules/types.ts similarity index 100% rename from src/modules/types.ts rename to packages/sdk/src/modules/types.ts diff --git a/src/modules/users.ts b/packages/sdk/src/modules/users.ts similarity index 100% rename from src/modules/users.ts rename to packages/sdk/src/modules/users.ts diff --git a/src/types.ts b/packages/sdk/src/types.ts similarity index 100% rename from src/types.ts rename to packages/sdk/src/types.ts diff --git a/src/utils/auth-utils.ts b/packages/sdk/src/utils/auth-utils.ts similarity index 100% rename from src/utils/auth-utils.ts rename to packages/sdk/src/utils/auth-utils.ts diff --git a/src/utils/auth-utils.types.ts b/packages/sdk/src/utils/auth-utils.types.ts similarity index 100% rename from src/utils/auth-utils.types.ts rename to packages/sdk/src/utils/auth-utils.types.ts diff --git a/src/utils/axios-client.ts b/packages/sdk/src/utils/axios-client.ts similarity index 100% rename from src/utils/axios-client.ts rename to packages/sdk/src/utils/axios-client.ts diff --git a/src/utils/axios-client.types.ts b/packages/sdk/src/utils/axios-client.types.ts similarity index 100% rename from src/utils/axios-client.types.ts rename to packages/sdk/src/utils/axios-client.types.ts diff --git a/src/utils/common.ts b/packages/sdk/src/utils/common.ts similarity index 100% rename from src/utils/common.ts rename to packages/sdk/src/utils/common.ts diff --git a/src/utils/fetch-with-auth.ts b/packages/sdk/src/utils/fetch-with-auth.ts similarity index 100% rename from src/utils/fetch-with-auth.ts rename to packages/sdk/src/utils/fetch-with-auth.ts diff --git a/src/utils/sharedInstance.ts b/packages/sdk/src/utils/sharedInstance.ts similarity index 100% rename from src/utils/sharedInstance.ts rename to packages/sdk/src/utils/sharedInstance.ts diff --git a/src/utils/socket-utils.ts b/packages/sdk/src/utils/socket-utils.ts similarity index 100% rename from src/utils/socket-utils.ts rename to packages/sdk/src/utils/socket-utils.ts diff --git a/tests/.env.example b/packages/sdk/tests/.env.example similarity index 100% rename from tests/.env.example rename to packages/sdk/tests/.env.example diff --git a/tests/e2e/auth.test.js b/packages/sdk/tests/e2e/auth.test.js similarity index 100% rename from tests/e2e/auth.test.js rename to packages/sdk/tests/e2e/auth.test.js diff --git a/tests/e2e/custom-integrations.test.js b/packages/sdk/tests/e2e/custom-integrations.test.js similarity index 100% rename from tests/e2e/custom-integrations.test.js rename to packages/sdk/tests/e2e/custom-integrations.test.js diff --git a/tests/e2e/entities.test.js b/packages/sdk/tests/e2e/entities.test.js similarity index 100% rename from tests/e2e/entities.test.js rename to packages/sdk/tests/e2e/entities.test.js diff --git a/tests/e2e/integrations.test.js b/packages/sdk/tests/e2e/integrations.test.js similarity index 100% rename from tests/e2e/integrations.test.js rename to packages/sdk/tests/e2e/integrations.test.js diff --git a/tests/setup.js b/packages/sdk/tests/setup.js similarity index 100% rename from tests/setup.js rename to packages/sdk/tests/setup.js diff --git a/tests/types/ai-gateway.types.ts b/packages/sdk/tests/types/ai-gateway.types.ts similarity index 100% rename from tests/types/ai-gateway.types.ts rename to packages/sdk/tests/types/ai-gateway.types.ts diff --git a/tests/types/connectors.types.ts b/packages/sdk/tests/types/connectors.types.ts similarity index 100% rename from tests/types/connectors.types.ts rename to packages/sdk/tests/types/connectors.types.ts diff --git a/tests/types/entities-filter.types.ts b/packages/sdk/tests/types/entities-filter.types.ts similarity index 100% rename from tests/types/entities-filter.types.ts rename to packages/sdk/tests/types/entities-filter.types.ts diff --git a/tests/types/entities-primitives.types.ts b/packages/sdk/tests/types/entities-primitives.types.ts similarity index 100% rename from tests/types/entities-primitives.types.ts rename to packages/sdk/tests/types/entities-primitives.types.ts diff --git a/tests/unit/actors.test.ts b/packages/sdk/tests/unit/actors.test.ts similarity index 100% rename from tests/unit/actors.test.ts rename to packages/sdk/tests/unit/actors.test.ts diff --git a/tests/unit/agents.test.ts b/packages/sdk/tests/unit/agents.test.ts similarity index 100% rename from tests/unit/agents.test.ts rename to packages/sdk/tests/unit/agents.test.ts diff --git a/tests/unit/ai-gateway.test.ts b/packages/sdk/tests/unit/ai-gateway.test.ts similarity index 100% rename from tests/unit/ai-gateway.test.ts rename to packages/sdk/tests/unit/ai-gateway.test.ts diff --git a/tests/unit/analytics.test.ts b/packages/sdk/tests/unit/analytics.test.ts similarity index 100% rename from tests/unit/analytics.test.ts rename to packages/sdk/tests/unit/analytics.test.ts diff --git a/tests/unit/anonymous-visitor-header.test.ts b/packages/sdk/tests/unit/anonymous-visitor-header.test.ts similarity index 100% rename from tests/unit/anonymous-visitor-header.test.ts rename to packages/sdk/tests/unit/anonymous-visitor-header.test.ts diff --git a/tests/unit/app.test.ts b/packages/sdk/tests/unit/app.test.ts similarity index 100% rename from tests/unit/app.test.ts rename to packages/sdk/tests/unit/app.test.ts diff --git a/tests/unit/auth.test.js b/packages/sdk/tests/unit/auth.test.js similarity index 100% rename from tests/unit/auth.test.js rename to packages/sdk/tests/unit/auth.test.js diff --git a/tests/unit/client.test.js b/packages/sdk/tests/unit/client.test.js similarity index 100% rename from tests/unit/client.test.js rename to packages/sdk/tests/unit/client.test.js diff --git a/tests/unit/connectors-proxy.test.ts b/packages/sdk/tests/unit/connectors-proxy.test.ts similarity index 100% rename from tests/unit/connectors-proxy.test.ts rename to packages/sdk/tests/unit/connectors-proxy.test.ts diff --git a/tests/unit/connectors.test.ts b/packages/sdk/tests/unit/connectors.test.ts similarity index 100% rename from tests/unit/connectors.test.ts rename to packages/sdk/tests/unit/connectors.test.ts diff --git a/tests/unit/custom-integrations.test.ts b/packages/sdk/tests/unit/custom-integrations.test.ts similarity index 100% rename from tests/unit/custom-integrations.test.ts rename to packages/sdk/tests/unit/custom-integrations.test.ts diff --git a/tests/unit/entities-primitives.test.ts b/packages/sdk/tests/unit/entities-primitives.test.ts similarity index 100% rename from tests/unit/entities-primitives.test.ts rename to packages/sdk/tests/unit/entities-primitives.test.ts diff --git a/tests/unit/entities-subscribe.test.ts b/packages/sdk/tests/unit/entities-subscribe.test.ts similarity index 100% rename from tests/unit/entities-subscribe.test.ts rename to packages/sdk/tests/unit/entities-subscribe.test.ts diff --git a/tests/unit/entities.test.ts b/packages/sdk/tests/unit/entities.test.ts similarity index 100% rename from tests/unit/entities.test.ts rename to packages/sdk/tests/unit/entities.test.ts diff --git a/tests/unit/fetch-with-auth.test.ts b/packages/sdk/tests/unit/fetch-with-auth.test.ts similarity index 100% rename from tests/unit/fetch-with-auth.test.ts rename to packages/sdk/tests/unit/fetch-with-auth.test.ts diff --git a/tests/unit/functions.test.ts b/packages/sdk/tests/unit/functions.test.ts similarity index 100% rename from tests/unit/functions.test.ts rename to packages/sdk/tests/unit/functions.test.ts diff --git a/tests/unit/integrations.test.js b/packages/sdk/tests/unit/integrations.test.js similarity index 100% rename from tests/unit/integrations.test.js rename to packages/sdk/tests/unit/integrations.test.js diff --git a/tests/unit/integrations.test.ts b/packages/sdk/tests/unit/integrations.test.ts similarity index 100% rename from tests/unit/integrations.test.ts rename to packages/sdk/tests/unit/integrations.test.ts diff --git a/tests/unit/react-native.test.ts b/packages/sdk/tests/unit/react-native.test.ts similarity index 100% rename from tests/unit/react-native.test.ts rename to packages/sdk/tests/unit/react-native.test.ts diff --git a/tests/unit/socket-utils.test.ts b/packages/sdk/tests/unit/socket-utils.test.ts similarity index 100% rename from tests/unit/socket-utils.test.ts rename to packages/sdk/tests/unit/socket-utils.test.ts diff --git a/tests/unit/sso.test.ts b/packages/sdk/tests/unit/sso.test.ts similarity index 100% rename from tests/unit/sso.test.ts rename to packages/sdk/tests/unit/sso.test.ts diff --git a/tests/unit/typedoc-returns.test.ts b/packages/sdk/tests/unit/typedoc-returns.test.ts similarity index 100% rename from tests/unit/typedoc-returns.test.ts rename to packages/sdk/tests/unit/typedoc-returns.test.ts diff --git a/tests/utils/circular-json-handler.js b/packages/sdk/tests/utils/circular-json-handler.js similarity index 100% rename from tests/utils/circular-json-handler.js rename to packages/sdk/tests/utils/circular-json-handler.js diff --git a/tests/utils/test-config.js b/packages/sdk/tests/utils/test-config.js similarity index 100% rename from tests/utils/test-config.js rename to packages/sdk/tests/utils/test-config.js diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json new file mode 100644 index 00000000..01385596 --- /dev/null +++ b/packages/sdk/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": [ + "src/**/*", + "src/**/*.d.ts" + ], + "exclude": [ + "node_modules", + "dist", + "**/*.test.ts", + "**/*.test.js" + ] +} diff --git a/tsconfig.type-tests.json b/packages/sdk/tsconfig.type-tests.json similarity index 100% rename from tsconfig.type-tests.json rename to packages/sdk/tsconfig.type-tests.json diff --git a/typedoc.json b/packages/sdk/typedoc.json similarity index 100% rename from typedoc.json rename to packages/sdk/typedoc.json diff --git a/vitest.config.ts b/packages/sdk/vitest.config.ts similarity index 100% rename from vitest.config.ts rename to packages/sdk/vitest.config.ts diff --git a/writing-docs.md b/packages/sdk/writing-docs.md similarity index 100% rename from writing-docs.md rename to packages/sdk/writing-docs.md diff --git a/tsconfig.json b/tsconfig.base.json similarity index 66% rename from tsconfig.json rename to tsconfig.base.json index 1cb3cd0a..001f7aff 100644 --- a/tsconfig.json +++ b/tsconfig.base.json @@ -2,9 +2,11 @@ "compilerOptions": { "target": "es2018", "module": "esnext", - "lib": ["dom", "esnext"], + "lib": [ + "dom", + "esnext" + ], "declaration": true, - "outDir": "./dist", "strict": true, "moduleResolution": "node", "esModuleInterop": true, @@ -13,7 +15,5 @@ "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "jsx": "react" - }, - "include": ["src/**/*", "src/**/*.d.ts"], - "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.js"] -} \ No newline at end of file + } +}