Skip to content

Commit

Permalink
chore: rename sdk-js to client (#55)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Alexandre BODIN <[email protected]>
  • Loading branch information
innerdvations and alexandrebodin authored Feb 13, 2025
1 parent f2b098f commit ba69fdf
Show file tree
Hide file tree
Showing 22 changed files with 181 additions and 175 deletions.
16 changes: 8 additions & 8 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ body:
- type: textarea
attributes:
label: Bug Description
description: Provide a clear and concise description of the issue or unexpected behavior related to the Strapi SDK client.
placeholder: Using the SDK client to fetch data from the "articles" collection does not return the expected results.
description: Provide a clear and concise description of the issue or unexpected behavior related to the Strapi Client.
placeholder: Using the Strapi client to fetch data from the "articles" collection does not return the expected results.
validations:
required: true

Expand All @@ -18,8 +18,8 @@ body:
placeholder: |
Example:
1. Initialize a new Strapi project with an "article" collection type defined as "...".
2. Configure the SDK client with your Strapi API URL and authentication token.
3. Perform a query to fetch entries from a collection: `sdk.collection('articles').find()`.
2. Configure the Strapi client with your Strapi API URL and authentication token.
3. Perform a query to fetch entries from a collection: `client.collection('articles').find()`.
4. Observe the unexpected behavior or error in the response/output.
validations:
required: true
Expand All @@ -35,7 +35,7 @@ body:
id: version
attributes:
label: Version
description: The version of the SDK that was used.
description: The version of the Strapi Client that was used.
placeholder: 1.0.0
validations:
required: true
Expand Down Expand Up @@ -73,7 +73,7 @@ body:
id: logs
attributes:
label: Logs
description: If available, please provide the logs generated while using the SDK.
description: If available, please provide the logs generated while using the client.
render: shell

- type: textarea
Expand All @@ -87,10 +87,10 @@ body:
attributes:
label: Confirmation Checklist
options:
- label: I have checked the existing [issues](https://github.com/strapi/sdk-js/issues)
- label: I have checked the existing [issues](https://github.com/strapi/client/issues)
required: true

- label: I agree to follow this project's [Code of Conduct](https://github.com/strapi/sdk-js/blob/main/CODE_OF_CONDUCT.md)
- label: I agree to follow this project's [Code of Conduct](https://github.com/strapi/client/blob/main/CODE_OF_CONDUCT.md)
required: true

- label: I would like to work on this issue
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<br />

<p align="center">
<a href="https://www.npmjs.org/package/@strapi/sdk-js">
<img src="https://img.shields.io/npm/v/@strapi/sdk-js/latest.svg" alt="NPM Version" />
<a href="https://www.npmjs.org/package/@strapi/client">
<img src="https://img.shields.io/npm/v/@strapi/client/latest.svg" alt="NPM Version" />
</a>
<a href="https://www.npmjs.com/package/@strapi/sdk-js" target="_blank">
<img src="https://img.shields.io/npm/dm/@strapi/sdk-js" alt="NPM downloads" />
<a href="https://www.npmjs.com/package/@strapi/client" target="_blank">
<img src="https://img.shields.io/npm/dm/@strapi/client" alt="NPM downloads" />
</a>
<a href="https://github.com/strapi/sdk-js/actions/workflows/tests.yml">
<img src="https://github.com/strapi/sdk-js/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
<a href="https://github.com/strapi/client/actions/workflows/tests.yml">
<img src="https://github.com/strapi/client/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
</a>
<a href="https://discord.strapi.io">
<img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
Expand All @@ -34,7 +34,7 @@
1. [Getting Started](#-getting-started)
- [Prerequisites](#pre-requisites)
- [Installation](#installation)
2. [Creating and Configuring an SDK Instance](#-creating-and-configuring-the-sdk-instance)
2. [Creating and Configuring a Strapi Client Instance](#-creating-and-configuring-the-sdk-instance)
- [Basic Configuration](#basic-configuration)
- [Authentication](#authentication)
- [API Token Authentication](#api-token-authentication)
Expand All @@ -57,58 +57,58 @@ Before you begin, ensure you have the following:

### Installation

Install the SDK as a dependency in your project:
Install the client as a dependency in your project:

**NPM**

```bash
npm install @strapi/sdk-js
npm install @strapi/client
```

**Yarn**

```bash
yarn add @strapi/sdk-js
yarn add @strapi/client
```

**pnpm**

```bash
pnpm add @strapi/sdk-js
pnpm add @strapi/client
```

## ⚙️ Creating and configuring the SDK Instance
## ⚙️ Creating and configuring the client Instance

### Basic configuration

To interact with your Strapi backend, initialize the SDK with your Strapi API base URL:
To interact with your Strapi backend, initialize the client with your Strapi API base URL:

```typescript
import { strapi } from '@strapi/sdk-js';
import { strapi } from '@strapi/client';

const sdk = strapi({ baseURL: 'http://localhost:1337/api' });
const client = strapi({ baseURL: 'http://localhost:1337/api' });
```

Alternatively, use a `<script>` tag in a browser environment:

```html
<script src="https://cdn.jsdelivr.net/npm/@strapi/sdk-js"></script>
<script src="https://cdn.jsdelivr.net/npm/@strapi/client"></script>

<script>
const sdk = strapi.strapi({ baseURL: 'http://localhost:1337/api' });
const client = strapi.strapi({ baseURL: 'http://localhost:1337/api' });
</script>
```

### Authentication

The SDK supports multiple authentication strategies for accessing authenticated content in your Strapi backend.
The client library supports multiple authentication strategies for accessing authenticated content in your Strapi backend.

#### API-Token authentication

If your Strapi instance uses API tokens, configure the SDK like this:
If your Strapi instance uses API tokens, configure the client like this:

```typescript
const sdk = strapi({
const client = strapi({
// Endpoint configuration
baseURL: 'http://localhost:1337/api',
// Auth configuration
Expand All @@ -118,7 +118,7 @@ const sdk = strapi({

## 📚 API Reference

The Strapi SDK instance provides key properties and utility methods for content and API interaction:
The Strapi client library instance provides key properties and utility methods for content and API interaction:

- **`baseURL`**: base URL of your Strapi backend.
- **`fetch`**: perform generic requests to the Strapi Content API using fetch-like syntax.
Expand All @@ -145,7 +145,7 @@ which can have multiple entries.
#### Examples:

```typescript
const articles = sdk.collection('articles');
const articles = client.collection('articles');

// Fetch all english articles sorted by title
const allArticles = await articles.find({
Expand Down Expand Up @@ -181,7 +181,7 @@ The `.single()` method provides a manager for working with single-type resources
#### Examples:

```typescript
const homepage = sdk.single('homepage');
const homepage = client.single('homepage');

// Fetch the default version of the homepage
const defaultHomepage = await homepage.find();
Expand Down Expand Up @@ -254,7 +254,7 @@ Below is a list of available namespaces to use:

## 🚀 Demo Projects

This repository includes demo projects located in the `/demo` directory to help you get started with using the Strapi SDK. The actual Strapi application is located in the `.strapi-app` directory.
This repository includes demo projects located in the `/demo` directory to help you get started with using the client. The actual Strapi application is located in the `.strapi-app` directory.

### Demo Structure

Expand All @@ -264,7 +264,7 @@ This repository includes demo projects located in the `/demo` directory to help

### Using Demo Scripts

The `package.json` includes several scripts to help you manage and run the demo projects. These scripts are designed to streamline the process of setting up and running the demo projects, making it easier for developers to test and interact with the SDK.
The `package.json` includes several scripts to help you manage and run the demo projects. These scripts are designed to streamline the process of setting up and running the demo projects, making it easier for developers to test and interact with the client.

The most important basic commands to get started are:

Expand Down Expand Up @@ -323,4 +323,4 @@ We plan to expand the demo projects to include:
- A basic HTML project.
- A Next.js project.

These additions will provide more examples of how to integrate the Strapi SDK into different types of applications.
These additions will provide more examples of how to integrate the client into different types of applications.
4 changes: 2 additions & 2 deletions demo/node-javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "demo-node-javascript",
"version": "1.0.0",
"description": "A Strapi SDK demo using a Node x JavaScript application",
"description": "A Strapi Client demo using a Node x JavaScript application",
"main": "index.js",
"scripts": {
"start": "node src/index.js",
"debug": "DEBUG=* node src/index.js"
},
"dependencies": {
"@strapi/sdk-js": "link:../..",
"@strapi/client": "link:../..",
"dotenv": "16.4.7"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion demo/node-javascript/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions demo/node-javascript/src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const { strapi } = require('@strapi/sdk-js');
const { strapi } = require('@strapi/client');
require('dotenv').config();

const api_token = process.env.FULL_ACCESS_TOKEN; // READ_ONLY_TOKEN is also available

console.log('Running with api token ' + api_token);

async function main() {
// Create the SDK instance
const sdk = strapi({ baseURL: 'http://localhost:1337/api', auth: api_token });
// Create the Strapi client instance
const client = strapi({ baseURL: 'http://localhost:1337/api', auth: api_token });

// Create a collection type query manager for the categories
const categories = sdk.collection('categories');
const categories = client.collection('categories');

// Fetch the list of all categories
const docs = await categories.find();
Expand Down
4 changes: 2 additions & 2 deletions demo/node-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "demo-node-typescript",
"version": "1.0.0",
"description": "A Strapi SDK demo using a Node x TypeScript application",
"description": "A Strapi Client demo using a Node x TypeScript application",
"main": "dist/index.js",
"private": true,
"type": "module",
Expand All @@ -12,7 +12,7 @@
"debug": "DEBUG=* node dist/index.js"
},
"dependencies": {
"@strapi/sdk-js": "link:../..",
"@strapi/client": "link:../..",
"dotenv": "16.4.7"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion demo/node-typescript/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions demo/node-typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { strapi } from '@strapi/sdk-js';
import { strapi } from '@strapi/client';
import * as dotenv from 'dotenv';
dotenv.config();

const api_token = process.env.FULL_ACCESS_TOKEN; // READ_ONLY_TOKEN is also available

console.log('Running with api token ' + api_token);

// Create the SDK instance
const sdk = strapi({ baseURL: 'http://localhost:1337/api', auth: api_token });
// Create the Strapi client instance
const client = strapi({ baseURL: 'http://localhost:1337/api', auth: api_token });
// Create a collection type query manager for the categories
const categories = sdk.collection('categories');
const categories = client.collection('categories');

// Fetch the list of all categories
const docs = await categories.find();
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"name": "@strapi/sdk-js",
"name": "@strapi/client",
"version": "1.0.0",
"description": "An SDK you can use the easily interface with Strapi from your javascript project",
"description": "The official client library to easily interface with Strapi from your JavaScript/TypeScript project",
"keywords": [
"strapi",
"sdk",
"js"
"library",
"client",
"js",
"ts"
],
"repository": {
"type": "git",
"url": "https://github.com/strapi/sdk-js.git"
"url": "https://github.com/strapi/client.git"
},
"license": "SEE LICENSE IN LICENSE",
"author": {
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import terser from '@rollup/plugin-terser';
const isProduction = process.env.NODE_ENV === 'production';

/**
* This configuration is designed to bundle the Strapi SDK for Node.js environments.
* This configuration is designed to bundle the Strapi Client for Node.js environments.
*
* It produces two outputs: one for the older CommonJS module system and one for the modern ES Module
* system, ensuring compatibility with a wide range of tools and runtimes.
Expand Down Expand Up @@ -69,7 +69,7 @@ const node_build = {
};

/**
* This configuration is designed to bundle the Strapi SDK for browser environments.
* This configuration is designed to bundle the Strapi Client for browser environments.
*
* It outputs using the IIFE format, which is suitable for use in web browsers.
*
Expand Down
2 changes: 1 addition & 1 deletion src/auth/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class AuthManager {
}

/**
* Registers the SDK default authentication providers in the factory so that they can be later selected.
* Registers the client default authentication providers in the factory so that they can be later selected.
*
* The default authentication providers are:
* - API Token ({@link ApiTokenAuthProvider})
Expand Down
2 changes: 1 addition & 1 deletion src/auth/providers/users-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type UsersPermissionsAuthPayload = Pick<
/**
* @experimental
* Authentication through users and permissions is experimental for the MVP of
* the Strapi SDK.
* the Strapi client.
*/
export class UsersPermissionsAuthProvider extends AbstractAuthProvider<UsersPermissionsAuthProviderOptions> {
public static readonly identifier = USERS_PERMISSIONS_AUTH_STRATEGY_IDENTIFIER;
Expand Down
Loading

0 comments on commit ba69fdf

Please sign in to comment.