@edifice.io/rest-client-base 2.5.4-feat-ENABLING-562.20251216132919 → 2.5.4-feat-ENABLING-562.20251216141508
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/cli.js +54 -0
- package/package.json +8 -4
- package/dist/browser/src/client/adapters/fetch-adapter.d.ts +0 -12
- package/dist/browser/src/client/adapters/http-adapter.d.ts +0 -8
- package/dist/browser/src/client/adapters/http-service-adapter.d.ts +0 -14
- package/dist/browser/src/client/base-api.client.d.ts +0 -29
- package/dist/browser/src/client/errors/api-error.d.ts +0 -11
- package/dist/browser/src/client/index.d.ts +0 -5
- package/dist/browser/src/decorators/custom-type.decorator.browser.d.ts +0 -3
- package/dist/browser/src/decorators/custom-type.decorator.node.d.ts +0 -3
- package/dist/browser/src/index.d.ts +0 -2
- package/dist/browser/tsconfig.browser.tsbuildinfo +0 -1
- package/dist/browser/vite.config.browser.d.ts +0 -2
- package/dist/browser/vite.config.node.d.ts +0 -2
- package/dist/browser/vite.config.react-native.d.ts +0 -2
- package/dist/node/src/client/adapters/fetch-adapter.d.ts +0 -12
- package/dist/node/src/client/adapters/http-adapter.d.ts +0 -8
- package/dist/node/src/client/adapters/http-service-adapter.d.ts +0 -14
- package/dist/node/src/client/base-api.client.d.ts +0 -29
- package/dist/node/src/client/errors/api-error.d.ts +0 -11
- package/dist/node/src/client/index.d.ts +0 -5
- package/dist/node/src/decorators/custom-type.decorator.browser.d.ts +0 -3
- package/dist/node/src/decorators/custom-type.decorator.node.d.ts +0 -3
- package/dist/node/src/index.d.ts +0 -2
- package/dist/node/tsconfig.tsbuildinfo +0 -1
- package/dist/node/vite.config.browser.d.ts +0 -2
- package/dist/node/vite.config.node.d.ts +0 -2
- package/dist/node/vite.config.react-native.d.ts +0 -2
- package/dist/react-native/src/client/adapters/fetch-adapter.d.ts +0 -12
- package/dist/react-native/src/client/adapters/http-adapter.d.ts +0 -8
- package/dist/react-native/src/client/adapters/http-service-adapter.d.ts +0 -14
- package/dist/react-native/src/client/base-api.client.d.ts +0 -29
- package/dist/react-native/src/client/errors/api-error.d.ts +0 -11
- package/dist/react-native/src/client/index.d.ts +0 -5
- package/dist/react-native/src/decorators/custom-type.decorator.browser.d.ts +0 -3
- package/dist/react-native/src/decorators/custom-type.decorator.node.d.ts +0 -3
- package/dist/react-native/src/index.d.ts +0 -2
- package/dist/react-native/tsconfig.browser.tsbuildinfo +0 -1
- package/dist/react-native/vite.config.browser.d.ts +0 -2
- package/dist/react-native/vite.config.node.d.ts +0 -2
- package/dist/react-native/vite.config.react-native.d.ts +0 -2
package/dist/node/cli.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const glob_1 = require("glob");
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const command = args[0];
|
|
10
|
+
const moduleFlag = args.indexOf('--module');
|
|
11
|
+
const moduleName = moduleFlag !== -1 ? args[moduleFlag + 1] : null;
|
|
12
|
+
function replaceImports(distDir, targetModule) {
|
|
13
|
+
const jsFiles = (0, glob_1.globSync)(`${distDir}/**/*.js`);
|
|
14
|
+
jsFiles.forEach((file) => {
|
|
15
|
+
let content = (0, fs_1.readFileSync)(file, 'utf-8');
|
|
16
|
+
// Replace relative imports from parent (..)
|
|
17
|
+
content = content.replace(/from\s+["']\.\.["']/g, `from "@edifice.io/rest-client-base/${targetModule}"`);
|
|
18
|
+
// Replace direct imports from the package
|
|
19
|
+
content = content.replace(/from\s+["']@edifice\.io\/rest-client-base["']/g, `from "@edifice.io/rest-client-base/${targetModule}"`);
|
|
20
|
+
(0, fs_1.writeFileSync)(file, content, 'utf-8');
|
|
21
|
+
});
|
|
22
|
+
console.log(`✅ Imports replaced in ${distDir} with @edifice.io/rest-client-base/${targetModule}`);
|
|
23
|
+
}
|
|
24
|
+
function initReactNative() {
|
|
25
|
+
(0, child_process_1.execSync)('mkdir -p dist/react-native', { stdio: 'inherit' });
|
|
26
|
+
(0, child_process_1.execSync)('cp -r dist/browser/* dist/react-native/', { stdio: 'inherit' });
|
|
27
|
+
(0, child_process_1.execSync)('find dist/react-native -name "*.node.js*" -delete', {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
});
|
|
30
|
+
console.log('✅ React Native distribution initialized from browser build');
|
|
31
|
+
}
|
|
32
|
+
switch (command) {
|
|
33
|
+
case 'init':
|
|
34
|
+
if (moduleName === 'react-native') {
|
|
35
|
+
initReactNative();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error('❌ Unknown module for init. Use: --module react-native');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case 'replace': {
|
|
43
|
+
if (!moduleName) {
|
|
44
|
+
console.error('❌ Missing --module flag. Use: --module browser|react-native');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const distDir = (0, path_1.join)(process.cwd(), 'dist', moduleName);
|
|
48
|
+
replaceImports(distDir, moduleName);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
default:
|
|
52
|
+
console.error('❌ Unknown command. Available commands: init, replace');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/rest-client-base",
|
|
3
|
-
"version": "2.5.4-feat-ENABLING-562.
|
|
3
|
+
"version": "2.5.4-feat-ENABLING-562.20251216141508",
|
|
4
4
|
"description": "Abstract base for Edifice client SDKs (no application-specific logic)",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"main": "./dist/node/index.js",
|
|
10
10
|
"module": "./dist/browser/index.js",
|
|
11
11
|
"types": "./dist/node/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"rest-client-base": "./dist/node/cli.js"
|
|
14
|
+
},
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
17
|
"types": "./dist/node/index.d.ts",
|
|
@@ -32,21 +35,22 @@
|
|
|
32
35
|
],
|
|
33
36
|
"dependencies": {},
|
|
34
37
|
"devDependencies": {
|
|
38
|
+
"glob": "11.0.0",
|
|
35
39
|
"class-transformer": "0.5.1",
|
|
36
40
|
"class-validator": "0.14.2",
|
|
37
41
|
"@nestjs/swagger": "11.2.0",
|
|
38
42
|
"path": "0.12.7",
|
|
39
43
|
"vite": "5.4.14",
|
|
40
44
|
"vite-plugin-dts": "4.5.4",
|
|
41
|
-
"@edifice.io/client": "2.5.4-feat-ENABLING-562.
|
|
45
|
+
"@edifice.io/client": "2.5.4-feat-ENABLING-562.20251216141508"
|
|
42
46
|
},
|
|
43
47
|
"scripts": {
|
|
44
48
|
"clean": "rm -rf dist node_modules",
|
|
45
49
|
"format": "prettier --write src",
|
|
46
50
|
"lint": "eslint src",
|
|
47
51
|
"lint:fix": "eslint src --fix",
|
|
48
|
-
"build": "pnpm run build:node && pnpm run build:browser && pnpm run build:react-native
|
|
49
|
-
"build:node": "vite build --config vite.config.node.ts",
|
|
52
|
+
"build": "pnpm run build:node && pnpm run build:browser && pnpm run build:react-native",
|
|
53
|
+
"build:node": "vite build --config vite.config.node.ts && tsc src/bin/cli.ts --outDir dist/node --module commonjs --target ES2020",
|
|
50
54
|
"build:browser": "vite build --config vite.config.browser.ts",
|
|
51
55
|
"build:react-native": "vite build --config vite.config.react-native.ts",
|
|
52
56
|
"build:types": "tsc --emitDeclarationOnly --outDir dist/node && tsc --emitDeclarationOnly -p tsconfig.browser.json --outDir dist/browser && tsc --emitDeclarationOnly -p tsconfig.browser.json --outDir dist/react-native"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { HttpAdapter } from './http-adapter';
|
|
2
|
-
export declare class FetchAdapter implements HttpAdapter {
|
|
3
|
-
private readonly fetchImpl;
|
|
4
|
-
constructor(fetchImpl?: typeof fetch);
|
|
5
|
-
private handleResponse;
|
|
6
|
-
get<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
7
|
-
post<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
8
|
-
put<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
9
|
-
patch<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
10
|
-
delete<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
11
|
-
deleteWithBody<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface HttpAdapter {
|
|
2
|
-
get<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
3
|
-
post<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
4
|
-
put<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
5
|
-
patch<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
6
|
-
delete<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
7
|
-
deleteWithBody<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { odeServices } from '@edifice.io/client';
|
|
2
|
-
import { HttpAdapter } from './http-adapter';
|
|
3
|
-
type HttpService = ReturnType<typeof odeServices.http>;
|
|
4
|
-
export declare class HttpServiceAdapter implements HttpAdapter {
|
|
5
|
-
private readonly httpService;
|
|
6
|
-
constructor(httpService: HttpService);
|
|
7
|
-
get<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
8
|
-
post<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
9
|
-
put<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
10
|
-
patch<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
11
|
-
delete<T>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
12
|
-
deleteWithBody<T>(url: string, body: unknown, headers?: Record<string, string>): Promise<T>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { HttpAdapter } from './adapters/http-adapter';
|
|
2
|
-
import type { odeServices } from '@edifice.io/client';
|
|
3
|
-
type HttpService = ReturnType<typeof odeServices.http>;
|
|
4
|
-
export type FetchFunction = typeof fetch;
|
|
5
|
-
export interface ApiClientOptions {
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
defaultHeaders?: Record<string, string>;
|
|
8
|
-
fetchImpl?: typeof fetch;
|
|
9
|
-
httpService?: HttpService;
|
|
10
|
-
httpAdapter?: HttpAdapter;
|
|
11
|
-
}
|
|
12
|
-
export interface RequestOptions {
|
|
13
|
-
headers?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
export declare abstract class BaseApiClient {
|
|
16
|
-
protected readonly baseUrl: string;
|
|
17
|
-
protected readonly defaultHeaders: Record<string, string>;
|
|
18
|
-
protected readonly httpAdapter: HttpAdapter;
|
|
19
|
-
constructor(options?: ApiClientOptions);
|
|
20
|
-
protected get<T>(endpoint: string, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
21
|
-
protected post<T, U = unknown>(endpoint: string, body: U, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
22
|
-
protected put<T, U = unknown>(endpoint: string, body: U, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
23
|
-
protected patch<T, U = unknown>(endpoint: string, body: U, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
24
|
-
protected delete<T = void>(endpoint: string, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
25
|
-
protected deleteWithBody<T, U = unknown>(endpoint: string, body: U, queryParams?: URLSearchParams, options?: RequestOptions): Promise<T>;
|
|
26
|
-
protected buildUrl(endpoint: string, queryParams?: URLSearchParams): string;
|
|
27
|
-
protected buildHeaders(additionalHeaders?: Record<string, string>): Record<string, string>;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class ApiError extends Error {
|
|
2
|
-
private _response;
|
|
3
|
-
private _jsonData;
|
|
4
|
-
private _textData;
|
|
5
|
-
constructor(response: Response, message?: string);
|
|
6
|
-
response(): Response;
|
|
7
|
-
status(): number;
|
|
8
|
-
statusText(): string;
|
|
9
|
-
json(): Promise<unknown>;
|
|
10
|
-
text(): Promise<string>;
|
|
11
|
-
}
|