baasix 0.1.5 → 0.1.6
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/CHANGELOG.md +7 -0
- package/README.md +2 -2
- package/dist/index.mjs +14 -14
- package/package.json +3 -3
- package/src/commands/extension.ts +3 -3
- package/src/commands/generate.ts +2 -2
- package/src/commands/init.ts +7 -7
- package/src/commands/migrate.ts +2 -2
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ baasix generate --url http://localhost:8056 --output ./src/types/baasix.d.ts
|
|
|
130
130
|
|
|
131
131
|
```typescript
|
|
132
132
|
import type { Product, Category, BaasixUser } from "./types/baasix";
|
|
133
|
-
import { createBaasix } from "@
|
|
133
|
+
import { createBaasix } from "@baasix/sdk";
|
|
134
134
|
|
|
135
135
|
const baasix = createBaasix({ url: "http://localhost:8056" });
|
|
136
136
|
|
|
@@ -201,7 +201,7 @@ baasix extension --type endpoint --name analytics
|
|
|
201
201
|
|
|
202
202
|
```javascript
|
|
203
203
|
// extensions/baasix-endpoint-analytics/index.js
|
|
204
|
-
import { APIError } from "@
|
|
204
|
+
import { APIError } from "@baasix/baasix";
|
|
205
205
|
|
|
206
206
|
export default {
|
|
207
207
|
id: "analytics",
|
package/dist/index.mjs
CHANGED
|
@@ -345,7 +345,7 @@ async function createApiProject(projectPath, config) {
|
|
|
345
345
|
start: "tsx server.js"
|
|
346
346
|
},
|
|
347
347
|
dependencies: {
|
|
348
|
-
"@
|
|
348
|
+
"@baasix/baasix": "latest",
|
|
349
349
|
"dotenv": "^16.3.1"
|
|
350
350
|
},
|
|
351
351
|
devDependencies: {
|
|
@@ -356,7 +356,7 @@ async function createApiProject(projectPath, config) {
|
|
|
356
356
|
path2.join(projectPath, "package.json"),
|
|
357
357
|
JSON.stringify(packageJson, null, 2)
|
|
358
358
|
);
|
|
359
|
-
const serverJs = `import { startServer } from "@
|
|
359
|
+
const serverJs = `import { startServer } from "@baasix/baasix";
|
|
360
360
|
|
|
361
361
|
startServer({
|
|
362
362
|
port: process.env.PORT || 8056,
|
|
@@ -700,7 +700,7 @@ async function createNextJsProject(projectPath, config, useAppRouter) {
|
|
|
700
700
|
lint: "next lint"
|
|
701
701
|
},
|
|
702
702
|
dependencies: {
|
|
703
|
-
"@
|
|
703
|
+
"@baasix/sdk": "latest",
|
|
704
704
|
next: "^14.0.0",
|
|
705
705
|
react: "^18.2.0",
|
|
706
706
|
"react-dom": "^18.2.0"
|
|
@@ -756,7 +756,7 @@ export default nextConfig;
|
|
|
756
756
|
if (useAppRouter) {
|
|
757
757
|
await fs.mkdir(path2.join(projectPath, "src", "app"), { recursive: true });
|
|
758
758
|
await fs.mkdir(path2.join(projectPath, "src", "lib"), { recursive: true });
|
|
759
|
-
const baasixClient = `import { createBaasix } from "@
|
|
759
|
+
const baasixClient = `import { createBaasix } from "@baasix/sdk";
|
|
760
760
|
|
|
761
761
|
export const baasix = createBaasix({
|
|
762
762
|
url: process.env.NEXT_PUBLIC_BAASIX_URL || "http://localhost:8056",
|
|
@@ -765,7 +765,7 @@ export const baasix = createBaasix({
|
|
|
765
765
|
});
|
|
766
766
|
|
|
767
767
|
// Re-export for convenience
|
|
768
|
-
export type { User, Role, QueryParams, Filter } from "@
|
|
768
|
+
export type { User, Role, QueryParams, Filter } from "@baasix/sdk";
|
|
769
769
|
`;
|
|
770
770
|
await fs.writeFile(path2.join(projectPath, "src", "lib", "baasix.ts"), baasixClient);
|
|
771
771
|
const layout = `import type { Metadata } from "next";
|
|
@@ -942,7 +942,7 @@ export default function Home() {
|
|
|
942
942
|
await fs.mkdir(path2.join(projectPath, "pages"), { recursive: true });
|
|
943
943
|
await fs.mkdir(path2.join(projectPath, "lib"), { recursive: true });
|
|
944
944
|
await fs.mkdir(path2.join(projectPath, "styles"), { recursive: true });
|
|
945
|
-
const baasixClient = `import { createBaasix } from "@
|
|
945
|
+
const baasixClient = `import { createBaasix } from "@baasix/sdk";
|
|
946
946
|
|
|
947
947
|
export const baasix = createBaasix({
|
|
948
948
|
url: process.env.NEXT_PUBLIC_BAASIX_URL || "http://localhost:8056",
|
|
@@ -950,7 +950,7 @@ export const baasix = createBaasix({
|
|
|
950
950
|
autoRefresh: true,
|
|
951
951
|
});
|
|
952
952
|
|
|
953
|
-
export type { User, Role, QueryParams, Filter } from "@
|
|
953
|
+
export type { User, Role, QueryParams, Filter } from "@baasix/sdk";
|
|
954
954
|
`;
|
|
955
955
|
await fs.writeFile(path2.join(projectPath, "lib", "baasix.ts"), baasixClient);
|
|
956
956
|
const app = `import type { AppProps } from "next/app";
|
|
@@ -1689,8 +1689,8 @@ function generateSDKTypes(schemas) {
|
|
|
1689
1689
|
" * Do not edit this file manually. Re-run 'baasix generate sdk-types' to update.",
|
|
1690
1690
|
" */",
|
|
1691
1691
|
"",
|
|
1692
|
-
'import { createBaasix } from "@
|
|
1693
|
-
'import type { QueryParams, Filter, PaginatedResponse } from "@
|
|
1692
|
+
'import { createBaasix } from "@baasix/sdk";',
|
|
1693
|
+
'import type { QueryParams, Filter, PaginatedResponse } from "@baasix/sdk";',
|
|
1694
1694
|
""
|
|
1695
1695
|
];
|
|
1696
1696
|
lines.push(generateTypeScriptTypes(schemas));
|
|
@@ -1849,7 +1849,7 @@ async function extensionAction(opts) {
|
|
|
1849
1849
|
async function createHookExtension(extensionDir, name, collection, useTypeScript) {
|
|
1850
1850
|
const ext = useTypeScript ? "ts" : "js";
|
|
1851
1851
|
const typeAnnotations = useTypeScript ? `
|
|
1852
|
-
import type { HooksService } from "@
|
|
1852
|
+
import type { HooksService } from "@baasix/baasix";
|
|
1853
1853
|
|
|
1854
1854
|
interface HookContext {
|
|
1855
1855
|
ItemsService: any;
|
|
@@ -1972,7 +1972,7 @@ async function createEndpointExtension(extensionDir, name, useTypeScript) {
|
|
|
1972
1972
|
const ext = useTypeScript ? "ts" : "js";
|
|
1973
1973
|
const typeAnnotations = useTypeScript ? `
|
|
1974
1974
|
import type { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
|
1975
|
-
import { APIError } from "@
|
|
1975
|
+
import { APIError } from "@baasix/baasix";
|
|
1976
1976
|
|
|
1977
1977
|
interface EndpointContext {
|
|
1978
1978
|
ItemsService: any;
|
|
@@ -1986,7 +1986,7 @@ interface RequestWithAccountability extends FastifyRequest {
|
|
|
1986
1986
|
role: { id: string; name: string };
|
|
1987
1987
|
};
|
|
1988
1988
|
}
|
|
1989
|
-
` : `import { APIError } from "@
|
|
1989
|
+
` : `import { APIError } from "@baasix/baasix";`;
|
|
1990
1990
|
const endpointContent = `${typeAnnotations}
|
|
1991
1991
|
|
|
1992
1992
|
/**
|
|
@@ -2340,7 +2340,7 @@ async function createMigration(s, cwd, name) {
|
|
|
2340
2340
|
|
|
2341
2341
|
/**
|
|
2342
2342
|
* Run the migration
|
|
2343
|
-
* @param {import("@
|
|
2343
|
+
* @param {import("@baasix/sdk").BaasixClient} baasix - Baasix client
|
|
2344
2344
|
*/
|
|
2345
2345
|
export async function up(baasix) {
|
|
2346
2346
|
// Example: Create a collection
|
|
@@ -2366,7 +2366,7 @@ export async function up(baasix) {
|
|
|
2366
2366
|
|
|
2367
2367
|
/**
|
|
2368
2368
|
* Reverse the migration
|
|
2369
|
-
* @param {import("@
|
|
2369
|
+
* @param {import("@baasix/sdk").BaasixClient} baasix - Baasix client
|
|
2370
2370
|
*/
|
|
2371
2371
|
export async function down(baasix) {
|
|
2372
2372
|
// Reverse the changes made in up()
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baasix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for Baasix Backend-as-a-Service",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"main": "./dist/index.mjs",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
11
|
-
"directory": "cli"
|
|
10
|
+
"url": "git+https://github.com/baasix/baasix.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://baasix.com/docs/cli-guide",
|
|
14
14
|
"scripts": {
|
|
@@ -173,7 +173,7 @@ async function createHookExtension(
|
|
|
173
173
|
|
|
174
174
|
const typeAnnotations = useTypeScript
|
|
175
175
|
? `
|
|
176
|
-
import type { HooksService } from "@
|
|
176
|
+
import type { HooksService } from "@baasix/baasix";
|
|
177
177
|
|
|
178
178
|
interface HookContext {
|
|
179
179
|
ItemsService: any;
|
|
@@ -309,7 +309,7 @@ async function createEndpointExtension(
|
|
|
309
309
|
const typeAnnotations = useTypeScript
|
|
310
310
|
? `
|
|
311
311
|
import type { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
|
312
|
-
import { APIError } from "@
|
|
312
|
+
import { APIError } from "@baasix/baasix";
|
|
313
313
|
|
|
314
314
|
interface EndpointContext {
|
|
315
315
|
ItemsService: any;
|
|
@@ -324,7 +324,7 @@ interface RequestWithAccountability extends FastifyRequest {
|
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
`
|
|
327
|
-
: `import { APIError } from "@
|
|
327
|
+
: `import { APIError } from "@baasix/baasix";`;
|
|
328
328
|
|
|
329
329
|
const endpointContent = `${typeAnnotations}
|
|
330
330
|
|
package/src/commands/generate.ts
CHANGED
|
@@ -463,8 +463,8 @@ function generateSDKTypes(schemas: SchemaInfo[]): string {
|
|
|
463
463
|
" * Do not edit this file manually. Re-run 'baasix generate sdk-types' to update.",
|
|
464
464
|
" */",
|
|
465
465
|
"",
|
|
466
|
-
'import { createBaasix } from "@
|
|
467
|
-
'import type { QueryParams, Filter, PaginatedResponse } from "@
|
|
466
|
+
'import { createBaasix } from "@baasix/sdk";',
|
|
467
|
+
'import type { QueryParams, Filter, PaginatedResponse } from "@baasix/sdk";',
|
|
468
468
|
"",
|
|
469
469
|
];
|
|
470
470
|
|
package/src/commands/init.ts
CHANGED
|
@@ -398,7 +398,7 @@ async function createApiProject(projectPath: string, config: ProjectConfig) {
|
|
|
398
398
|
start: "tsx server.js",
|
|
399
399
|
},
|
|
400
400
|
dependencies: {
|
|
401
|
-
"@
|
|
401
|
+
"@baasix/baasix": "latest",
|
|
402
402
|
"dotenv": "^16.3.1",
|
|
403
403
|
},
|
|
404
404
|
devDependencies: {
|
|
@@ -412,7 +412,7 @@ async function createApiProject(projectPath: string, config: ProjectConfig) {
|
|
|
412
412
|
);
|
|
413
413
|
|
|
414
414
|
// server.js
|
|
415
|
-
const serverJs = `import { startServer } from "@
|
|
415
|
+
const serverJs = `import { startServer } from "@baasix/baasix";
|
|
416
416
|
|
|
417
417
|
startServer({
|
|
418
418
|
port: process.env.PORT || 8056,
|
|
@@ -812,7 +812,7 @@ async function createNextJsProject(projectPath: string, config: ProjectConfig, u
|
|
|
812
812
|
lint: "next lint",
|
|
813
813
|
},
|
|
814
814
|
dependencies: {
|
|
815
|
-
"@
|
|
815
|
+
"@baasix/sdk": "latest",
|
|
816
816
|
next: "^14.0.0",
|
|
817
817
|
react: "^18.2.0",
|
|
818
818
|
"react-dom": "^18.2.0",
|
|
@@ -881,7 +881,7 @@ export default nextConfig;
|
|
|
881
881
|
await fs.mkdir(path.join(projectPath, "src", "lib"), { recursive: true });
|
|
882
882
|
|
|
883
883
|
// src/lib/baasix.ts - SDK client
|
|
884
|
-
const baasixClient = `import { createBaasix } from "@
|
|
884
|
+
const baasixClient = `import { createBaasix } from "@baasix/sdk";
|
|
885
885
|
|
|
886
886
|
export const baasix = createBaasix({
|
|
887
887
|
url: process.env.NEXT_PUBLIC_BAASIX_URL || "http://localhost:8056",
|
|
@@ -890,7 +890,7 @@ export const baasix = createBaasix({
|
|
|
890
890
|
});
|
|
891
891
|
|
|
892
892
|
// Re-export for convenience
|
|
893
|
-
export type { User, Role, QueryParams, Filter } from "@
|
|
893
|
+
export type { User, Role, QueryParams, Filter } from "@baasix/sdk";
|
|
894
894
|
`;
|
|
895
895
|
|
|
896
896
|
await fs.writeFile(path.join(projectPath, "src", "lib", "baasix.ts"), baasixClient);
|
|
@@ -1081,7 +1081,7 @@ export default function Home() {
|
|
|
1081
1081
|
await fs.mkdir(path.join(projectPath, "styles"), { recursive: true });
|
|
1082
1082
|
|
|
1083
1083
|
// lib/baasix.ts
|
|
1084
|
-
const baasixClient = `import { createBaasix } from "@
|
|
1084
|
+
const baasixClient = `import { createBaasix } from "@baasix/sdk";
|
|
1085
1085
|
|
|
1086
1086
|
export const baasix = createBaasix({
|
|
1087
1087
|
url: process.env.NEXT_PUBLIC_BAASIX_URL || "http://localhost:8056",
|
|
@@ -1089,7 +1089,7 @@ export const baasix = createBaasix({
|
|
|
1089
1089
|
autoRefresh: true,
|
|
1090
1090
|
});
|
|
1091
1091
|
|
|
1092
|
-
export type { User, Role, QueryParams, Filter } from "@
|
|
1092
|
+
export type { User, Role, QueryParams, Filter } from "@baasix/sdk";
|
|
1093
1093
|
`;
|
|
1094
1094
|
|
|
1095
1095
|
await fs.writeFile(path.join(projectPath, "lib", "baasix.ts"), baasixClient);
|
package/src/commands/migrate.ts
CHANGED
|
@@ -344,7 +344,7 @@ async function createMigration(
|
|
|
344
344
|
|
|
345
345
|
/**
|
|
346
346
|
* Run the migration
|
|
347
|
-
* @param {import("@
|
|
347
|
+
* @param {import("@baasix/sdk").BaasixClient} baasix - Baasix client
|
|
348
348
|
*/
|
|
349
349
|
export async function up(baasix) {
|
|
350
350
|
// Example: Create a collection
|
|
@@ -370,7 +370,7 @@ export async function up(baasix) {
|
|
|
370
370
|
|
|
371
371
|
/**
|
|
372
372
|
* Reverse the migration
|
|
373
|
-
* @param {import("@
|
|
373
|
+
* @param {import("@baasix/sdk").BaasixClient} baasix - Baasix client
|
|
374
374
|
*/
|
|
375
375
|
export async function down(baasix) {
|
|
376
376
|
// Reverse the changes made in up()
|