fix: react native uuid compatibility (#39)

This commit is contained in:
Daniel Rochetti 2023-12-21 11:49:44 -08:00 committed by GitHub
parent f7e7541738
commit 208073ce17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 10 deletions

View File

@ -1,7 +1,7 @@
{
"name": "@fal-ai/serverless-client",
"description": "The fal serverless JS/TS client",
"version": "0.7.3",
"version": "0.7.4",
"license": "MIT",
"repository": {
"type": "git",
@ -17,7 +17,8 @@
],
"dependencies": {
"@msgpack/msgpack": "^3.0.0-beta2",
"robot3": "^0.4.1"
"robot3": "^0.4.1",
"uuid-random": "^1.3.2"
},
"engines": {
"node": ">=18.0.0"

View File

@ -1,10 +1,10 @@
import { randomUUID } from 'crypto';
import uuid from 'uuid-random';
import { getConfig } from './config';
import { buildUrl } from './function';
describe('The function test suite', () => {
it('should build the URL with a function UUIDv4', () => {
const id = randomUUID();
const id = uuid();
const url = buildUrl(`12345/${id}`);
expect(url).toMatch(`trigger/12345/${id}`);
});

View File

@ -12,6 +12,7 @@ import {
state,
transition,
} from 'robot3';
import uuid from 'uuid-random';
import { getConfig, getRestApiUrl } from './config';
import { dispatchRequest } from './request';
import { ApiError } from './response';
@ -391,7 +392,7 @@ export const realtimeImpl: RealtimeClient = {
const {
// if running on React in the server, set clientOnly to true by default
clientOnly = isReact() && !isBrowser(),
connectionKey = crypto.randomUUID(),
connectionKey = uuid(),
maxBuffering,
throttleInterval = DEFAULT_THROTTLE_INTERVAL,
} = handler;
@ -530,7 +531,7 @@ export const realtimeImpl: RealtimeClient = {
? input
: {
...input,
request_id: input['request_id'] ?? crypto.randomUUID(),
request_id: input['request_id'] ?? uuid(),
};
stateMachine.throttledSend({

View File

@ -1,9 +1,9 @@
import { randomUUID } from 'crypto';
import uuid from 'uuid-random';
import { isUUIDv4 } from './utils';
describe('The utils test suite', () => {
it('should match a valid v4 uuid', () => {
const id = randomUUID();
const id = uuid();
expect(isUUIDv4(id)).toBe(true);
});

View File

@ -5,6 +5,7 @@
"outDir": "../../dist/out-tsc",
"inlineSources": true,
"declaration": true,
"esModuleInterop": true,
"allowJs": true,
"checkJs": false,
"types": ["node"]

View File

@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]

8
package-lock.json generated
View File

@ -31,7 +31,8 @@
"regenerator-runtime": "0.13.7",
"robot3": "^0.4.1",
"ts-morph": "^17.0.1",
"tslib": "^2.3.0"
"tslib": "^2.3.0",
"uuid-random": "^1.3.2"
},
"devDependencies": {
"@commitlint/cli": "^17.0.0",
@ -27990,6 +27991,11 @@
"uuid": "dist/bin/uuid"
}
},
"node_modules/uuid-random": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/uuid-random/-/uuid-random-1.3.2.tgz",
"integrity": "sha512-UOzej0Le/UgkbWEO8flm+0y+G+ljUon1QWTEZOq1rnMAsxo2+SckbiZdKzAHHlVh6gJqI1TjC/xwgR50MuCrBQ=="
},
"node_modules/v8-compile-cache": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",

View File

@ -47,7 +47,8 @@
"regenerator-runtime": "0.13.7",
"robot3": "^0.4.1",
"ts-morph": "^17.0.1",
"tslib": "^2.3.0"
"tslib": "^2.3.0",
"uuid-random": "^1.3.2"
},
"devDependencies": {
"@commitlint/cli": "^17.0.0",