Skip to content

Commit

Permalink
Remove remaining references to JSON API (#248)
Browse files Browse the repository at this point in the history
* remove remaining JSON API references in bin dir

* rename to Data API in some other places
  • Loading branch information
vkarpov15 authored Sep 18, 2024
1 parent 4f272ec commit 6f0dd18
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions bin/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ services:
timeout: 10s
retries: 10

jsonapi:
image: stargateio/jsonapi:${JSONTAG}
dataapi:
image: stargateio/data-api:${DATAAPITAG}
depends_on:
coordinator:
condition: service_healthy
Expand Down
18 changes: 9 additions & 9 deletions bin/start_data_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ then
fi

SGTAG=$stargate_version
JSONTAG=$data_api_version
DATAAPITAG=$data_api_version


while getopts "qr:t:j:" opt; do
Expand All @@ -31,13 +31,13 @@ while getopts "qr:t:j:" opt; do
echo "Using Stargate version $SGTAG"
;;
j)
JSONTAG=$OPTARG
echo "Using JSON API version $JSONTAG"
DATAAPITAG=$OPTARG
echo "Using Data API version $DATAAPITAG"
;;
\?)
echo "Valid options:"
echo " -t <tag> - use Docker images tagged with specified Stargate version (will pull images from Docker Hub if needed)"
echo " -j <tag> - use Docker images tagged with specified JSON API version (will pull images from Docker Hub if needed)"
echo " -j <tag> - use Docker images tagged with specified Data API version (will pull images from Docker Hub if needed)"
echo " -q - enable request logging for APIs in 'io.quarkus.http.access-log' (default: disabled)"
echo " -r - specify root log level for APIs (defaults to INFO); usually DEBUG, WARN or ERROR"
exit 1
Expand All @@ -47,22 +47,22 @@ done

if [ -z "$SGTAG" ]
then
echo "Missing stargate version (option -t). For example -t v2.0.8"
echo "Missing Stargate version (option -t). For example -t v2.0.8"
exit 1
fi

if [ -z "$JSONTAG" ]
if [ -z "$DATAAPITAG" ]
then
echo "Missing JSON API version (option -j). For example -j v1.0.0-ALPHA-1"
echo "Missing Data API version (option -j). For example -j v1.0.0-ALPHA-1"
exit 1
fi

export LOGLEVEL
export REQUESTLOG
export SGTAG
export JSONTAG
export DATAAPITAG

echo "Running with Stargate $SGTAG, JSON API $JSONTAG"
echo "Running with Stargate $SGTAG, Data API $DATAAPITAG"

if which docker-compose
then
Expand Down
6 changes: 3 additions & 3 deletions bin/start_json_api.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set REQUESTLOG=false
set SCRIPTS_HOME=%~dp0
For /F "tokens=1* delims==" %%A IN (%SCRIPTS_HOME%\..\api-compatibility.versions) DO (
IF "%%A"=="stargate_version" set SGTAG=%%B
IF "%%A"=="data_api_version" set JSONTAG=%%B
IF "%%A"=="data_api_version" set DATAAPITAG=%%B
)
@echo on
echo "Running with Stargate %SGTAG%, Data API %JSONTAG%"
echo "Running with Stargate %SGTAG%, Data API %DATAAPITAG%"
@echo off
docker-compose -f %SCRIPTS_HOME%\docker-compose.yml up -d
docker-compose -f %SCRIPTS_HOME%\docker-compose.yml up -d
4 changes: 2 additions & 2 deletions src/client/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class HTTPClient {
if (typeof window !== 'undefined') {
throw new Error('not for use in a web browser');
}
// set the baseURL to Astra, if the user provides a JSON API URL, use that instead.
// set the baseURL to Astra, if the user provides a Data API URL, use that instead.
if (options.baseUrl) {
this.baseUrl = options.baseUrl;
} else {
Expand Down Expand Up @@ -422,4 +422,4 @@ function cleanupOptions(commandName: string, command: Record<string, any>, optio
}
});
}
}
}
10 changes: 5 additions & 5 deletions src/collections/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class Client {
}

/**
* Setup a connection to the Astra/Stargate JSON API
* @param uri an Stargate JSON API uri (Eg. http://localhost:8181/v1/testks1) where testks1 is the name of the keyspace/Namespace which should always be the last part of the URL
* Setup a connection to the Astra/Stargate Data API
* @param uri an Stargate Data API uri (Eg. http://localhost:8181/v1/testks1) where testks1 is the name of the keyspace/Namespace which should always be the last part of the URL
* @returns MongoClient
*/
static async connect(uri: string, options?: ClientOptions | null): Promise<Client> {
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Client {
}

/**
* Connect the MongoClient instance to JSON API (create Namespace automatically when the 'createNamespaceOnConnect' flag is set to true)
* Connect the MongoClient instance to Data API (create Namespace automatically when the 'createNamespaceOnConnect' flag is set to true)
* @returns a MongoClient instance
*/
async connect(): Promise<Client> {
Expand All @@ -106,8 +106,8 @@ export class Client {
}

/**
* Use a JSON API keyspace
* @param dbName the JSON API keyspace to connect to
* Use a Data API keyspace
* @param dbName the Data API keyspace to connect to
* @returns Db
*/
db(dbName?: string): Db {
Expand Down
2 changes: 1 addition & 1 deletion src/collections/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class FindCursor {
!('$vectorize' in this.options.sort) &&
(this.options.limit == null || this.options.limit > 20);
if (isOverPageSizeLimit) {
throw new Error('Cannot set sort option without limit <= 20, JSON API can currently only return 20 documents with sort');
throw new Error('Cannot set sort option without limit <= 20, Data API can currently only return 20 documents with sort');
}

this.limit = options?.limit || Infinity;
Expand Down
4 changes: 2 additions & 2 deletions src/collections/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class _UpdateManyOptions {

export interface UpdateManyOptions extends _UpdateManyOptions {}

// `usePagination` is supported as user-specified option, but not passed to JSON API
// `usePagination` is supported as user-specified option, but not passed to Data API
export const updateManyInternalOptionsKeys: Set<string> = new Set(
Object.keys(new _UpdateManyOptions).filter(key => key !== 'usePagination')
);
Expand Down Expand Up @@ -163,4 +163,4 @@ export interface ListCollectionOptions extends _ListCollectionOptions {}

export const listCollectionOptionsKeys: Set<string> = new Set(
Object.keys(new _ListCollectionOptions)
);
);
8 changes: 4 additions & 4 deletions src/collections/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getBaseAPIPath(pathFromUrl?: string | null) {
}

/**
* Create an Astra connection URI while connecting to Astra JSON API
* Create an Astra connection URI while connecting to Astra Data API
* @param apiEndpoint the database API Endpoint of the Astra database
* @param apiToken an Astra application token
* @param namespace the namespace to connect to
Expand Down Expand Up @@ -98,8 +98,8 @@ export function createAstraUri (
}

/**
* Create a JSON API connection URI while connecting to Open source JSON API
* @param baseUrl the base URL of the JSON API
* Create a Data API connection URI while connecting to Open source Data API
* @param baseUrl the base URL of the Data API
* @param keyspace the keyspace to connect to
* @param username the username to connect with
* @param password the password to connect with
Expand All @@ -124,7 +124,7 @@ export function createStargateUri(
}

/**
* Get an access token from Stargate (this is useful while connecting to open source JSON API)
* Get an access token from Stargate (this is useful while connecting to open source Data API)
* @param username Username
* @param password Password
* @returns access token as string
Expand Down
4 changes: 2 additions & 2 deletions tests/collections/collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe(`StargateMongoose - ${testClientName} Connection - collections.collecti
}
assert.ok(error);
if (isAstra) {
//In Astra, it returns a 413 error prior to reaching the JSON API
//In Astra, it returns a 413 error prior to reaching the Data API
assert.strictEqual(error.errors[0].message, 'Request failed with status code 413');
} else {
assert.strictEqual(
Expand Down Expand Up @@ -2575,7 +2575,7 @@ describe(`StargateMongoose - ${testClientName} Connection - collections.collecti
}
await assert.rejects(
async () => collection.find({}, { sort: { num: -1 }, limit: 22 }),
/JSON API can currently only return 20 documents with sort/
/Data API can currently only return 20 documents with sort/
);
});
it('should findOne with sort', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/collections/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Options tests', async () => {
// @ts-ignore
const product1 = new Product({ name: 'Product 1', price: 10, isCertified: true });
await product1.save();
//runValidations is not a flag supported by JSON API, so it should be removed by stargate-mongoose
//runValidations is not a flag supported by Data API, so it should be removed by stargate-mongoose
await Product.deleteOne({ name: 'Product 1' }, { runValidations: true } as unknown as Record<string, never>);
const product1Deleted = await Product.findOne({ name: 'Product 1' });
assert.strictEqual(product1Deleted, null);
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ describe('Mongoose Model API level tests', async () => {
let cursor = Product.find().sort({ product: 1 }).cursor();
await assert.rejects(
cursor.next(),
/JSON API can currently only return 20 documents with sort/
/Data API can currently only return 20 documents with sort/
);

cursor = await Product.find().sort({ product: 1 }).limit(20).cursor();
Expand Down

0 comments on commit 6f0dd18

Please sign in to comment.