@layers/amba 0.1.1 → 1.0.1
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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/_internal/codegen.d.ts +3 -3
- package/dist/index.js +33 -36
- package/package.json +8 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# `@layers/amba` — the amba CLI
|
|
2
2
|
|
|
3
3
|
amba is an agent-native backend-as-a-service for mobile apps: functions,
|
|
4
|
-
collections, storage, AI
|
|
5
|
-
|
|
4
|
+
collections, storage, AI, queues, and static sites — one CLI to spin up
|
|
5
|
+
your project and ship to production.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Reads every collection schema for a project from the admin API and
|
|
5
5
|
* emits a single `.amba/types.d.ts` declaration body that augments the
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
6
|
+
* Amba client SDK modules so `Amba.collections.<name>`,
|
|
7
|
+
* `client.collections.<name>`, and `ctx.collections.<name>` are
|
|
8
|
+
* statically typed.
|
|
9
9
|
*/
|
|
10
10
|
export interface CodegenHttpClient {
|
|
11
11
|
/** Minimal contract — the engine only needs GET. */
|
package/dist/index.js
CHANGED
|
@@ -629,7 +629,7 @@ async function validateApiKey(apiKey) {
|
|
|
629
629
|
* Generate AMBA.md project context file for AI agents.
|
|
630
630
|
*/
|
|
631
631
|
function generateAmbaMarkdown(opts) {
|
|
632
|
-
const sdkPackage = opts.framework === "expo" ? "@layers/amba-expo" : "@layers/amba-
|
|
632
|
+
const sdkPackage = opts.framework === "expo" ? "@layers/amba-expo" : opts.framework === "react-native" ? "@layers/amba-react-native" : "@layers/amba-web";
|
|
633
633
|
const providerExample = opts.framework === "expo" ? `
|
|
634
634
|
### Client Setup
|
|
635
635
|
|
|
@@ -641,7 +641,7 @@ import { Amba } from '@layers/amba-expo';
|
|
|
641
641
|
|
|
642
642
|
export default function RootLayout() {
|
|
643
643
|
useEffect(() => {
|
|
644
|
-
Amba.
|
|
644
|
+
Amba.configure({
|
|
645
645
|
projectId: process.env.EXPO_PUBLIC_AMBA_PROJECT_ID!,
|
|
646
646
|
apiKey: process.env.EXPO_PUBLIC_AMBA_API_KEY!,
|
|
647
647
|
});
|
|
@@ -659,16 +659,16 @@ import { Amba } from '@layers/amba-expo';
|
|
|
659
659
|
export default function MyComponent() {
|
|
660
660
|
const onPress = async () => {
|
|
661
661
|
// Track an event
|
|
662
|
-
await Amba.track('lesson_completed', { lesson_id: '123' });
|
|
662
|
+
await Amba.events.track('lesson_completed', { lesson_id: '123' });
|
|
663
663
|
|
|
664
664
|
// Sign in with Apple (requires expo-apple-authentication)
|
|
665
665
|
await Amba.signInWithApple();
|
|
666
666
|
|
|
667
667
|
// Read remote config
|
|
668
|
-
const showBanner = Amba.
|
|
668
|
+
const showBanner = await Amba.config.fetch();
|
|
669
669
|
|
|
670
|
-
//
|
|
671
|
-
|
|
670
|
+
// Email sign-in
|
|
671
|
+
await Amba.auth.signInWithEmail('user@example.com', 'hunter2');
|
|
672
672
|
};
|
|
673
673
|
|
|
674
674
|
// ...
|
|
@@ -677,23 +677,21 @@ export default function MyComponent() {
|
|
|
677
677
|
### Client Setup
|
|
678
678
|
|
|
679
679
|
\`\`\`typescript
|
|
680
|
-
import { Amba } from '
|
|
680
|
+
import { Amba } from '${sdkPackage}';
|
|
681
681
|
|
|
682
|
-
Amba.configure({
|
|
682
|
+
await Amba.configure({
|
|
683
683
|
projectId: process.env.AMBA_PROJECT_ID!,
|
|
684
684
|
apiKey: process.env.AMBA_API_KEY!,
|
|
685
685
|
});
|
|
686
686
|
|
|
687
|
-
await Amba.client.init();
|
|
688
|
-
|
|
689
687
|
// Track an event
|
|
690
|
-
await Amba.
|
|
688
|
+
await Amba.events.track('page_viewed', { page: '/pricing' });
|
|
691
689
|
|
|
692
|
-
//
|
|
693
|
-
const config = Amba.
|
|
690
|
+
// Read remote config
|
|
691
|
+
const config = await Amba.config.fetch();
|
|
694
692
|
|
|
695
|
-
//
|
|
696
|
-
await Amba.
|
|
693
|
+
// Email sign-in
|
|
694
|
+
await Amba.auth.signInWithEmail('user@example.com', 'hunter2');
|
|
697
695
|
\`\`\``;
|
|
698
696
|
return `# Amba Project Context
|
|
699
697
|
|
|
@@ -749,7 +747,7 @@ amba config set <key> <value> # Set a config value
|
|
|
749
747
|
* Generate .cursor/rules/amba.mdc Cursor rules file.
|
|
750
748
|
*/
|
|
751
749
|
function generateCursorRules(opts) {
|
|
752
|
-
const sdk = opts.framework === "expo" ? "@layers/amba-expo" : "@layers/amba-
|
|
750
|
+
const sdk = opts.framework === "expo" ? "@layers/amba-expo" : opts.framework === "react-native" ? "@layers/amba-react-native" : "@layers/amba-web";
|
|
753
751
|
return `---
|
|
754
752
|
description: Rules for working with the Amba SDK in this project
|
|
755
753
|
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
@@ -853,9 +851,9 @@ async function detectFramework(cwd) {
|
|
|
853
851
|
function getSdkPackage(framework) {
|
|
854
852
|
switch (framework) {
|
|
855
853
|
case "expo": return "@layers/amba-expo";
|
|
856
|
-
case "react-native": return "@layers/amba-
|
|
857
|
-
case "web": return "@layers/amba-
|
|
858
|
-
case "unknown": return "@layers/amba-
|
|
854
|
+
case "react-native": return "@layers/amba-react-native";
|
|
855
|
+
case "web": return "@layers/amba-web";
|
|
856
|
+
case "unknown": return "@layers/amba-web";
|
|
859
857
|
}
|
|
860
858
|
}
|
|
861
859
|
async function writeExampleScaffold(cwd, framework, projectName) {
|
|
@@ -887,7 +885,7 @@ export function AmbaExample(): null {
|
|
|
887
885
|
* Call Amba.init() once at application startup (after env is loaded).
|
|
888
886
|
* Requires AMBA_PROJECT_ID + AMBA_API_KEY in your environment.
|
|
889
887
|
*/
|
|
890
|
-
import { Amba } from '@layers/amba-
|
|
888
|
+
import { Amba } from '@layers/amba-web';
|
|
891
889
|
|
|
892
890
|
export async function initAmba(): Promise<void> {
|
|
893
891
|
await Amba.init({
|
|
@@ -2014,7 +2012,6 @@ async function exportUsers(projectId, opts) {
|
|
|
2014
2012
|
}
|
|
2015
2013
|
sink.write(chunk);
|
|
2016
2014
|
}
|
|
2017
|
-
if (pending.length > 0) sink.write(pending);
|
|
2018
2015
|
await sink.close();
|
|
2019
2016
|
if (process.stderr.isTTY) process.stderr.write("\n");
|
|
2020
2017
|
if (resolvedPath) {
|
|
@@ -2222,7 +2219,9 @@ function renderJson(domains) {
|
|
|
2222
2219
|
function renderTypescript(domains) {
|
|
2223
2220
|
const lines = [
|
|
2224
2221
|
"// Auto-generated by `amba schema export --format=typescript`.",
|
|
2225
|
-
"// For the canonical types, import from
|
|
2222
|
+
"// For the canonical types, import from your Amba client SDK",
|
|
2223
|
+
"// (`@layers/amba-web`, `@layers/amba-expo`, `@layers/amba-react-native`,",
|
|
2224
|
+
"// or `@layers/amba-node`).",
|
|
2226
2225
|
""
|
|
2227
2226
|
];
|
|
2228
2227
|
for (const d of domains) {
|
|
@@ -3117,8 +3116,8 @@ const HEADER_BANNER = `// .amba/types.d.ts
|
|
|
3117
3116
|
// AUTO-GENERATED by \`amba types generate\` — do not edit by hand.
|
|
3118
3117
|
//
|
|
3119
3118
|
// This file is regenerated whenever you run the CLI. It declares one
|
|
3120
|
-
// interface per customer collection and module-augments
|
|
3121
|
-
//
|
|
3119
|
+
// interface per customer collection and module-augments the Amba client
|
|
3120
|
+
// SDKs so \`Amba.collections.<name>\`, \`client.collections.<name>\`,
|
|
3122
3121
|
// and \`ctx.collections.<name>\` (Worker side) are all statically typed.
|
|
3123
3122
|
//
|
|
3124
3123
|
// Commit OR gitignore at your discretion. The shape mirrors your current
|
|
@@ -3126,21 +3125,19 @@ const HEADER_BANNER = `// .amba/types.d.ts
|
|
|
3126
3125
|
function emitDeclarations(collections, bannerTimestamp) {
|
|
3127
3126
|
const banner = bannerTimestamp ? `${HEADER_BANNER}\n// Generated: ${bannerTimestamp}` : HEADER_BANNER;
|
|
3128
3127
|
const interfaces = collections.map((c) => emitInterface(c)).join("\n\n");
|
|
3129
|
-
const augmentClient = collections.length ?
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
const augmentFunctions = collections.length ? `
|
|
3137
|
-
declare module '@layers/amba-functions' {
|
|
3128
|
+
const augmentClient = collections.length ? [
|
|
3129
|
+
"@layers/amba-web",
|
|
3130
|
+
"@layers/amba-expo",
|
|
3131
|
+
"@layers/amba-react-native",
|
|
3132
|
+
"@layers/amba-node"
|
|
3133
|
+
].map((pkg) => `
|
|
3134
|
+
declare module '${pkg}' {
|
|
3138
3135
|
interface CollectionsRoot {
|
|
3139
|
-
${collections.map((c) => ` readonly ${tsLiteralKey(c.name)}: import('
|
|
3136
|
+
${collections.map((c) => ` readonly ${tsLiteralKey(c.name)}: import('${pkg}').ClientCollection<Amba.collections.${tsTypeName(c.name)}>;`).join("\n")}
|
|
3140
3137
|
}
|
|
3141
3138
|
}
|
|
3142
|
-
` : "";
|
|
3143
|
-
return `${banner}\n\nexport {};\n\ndeclare global {\n namespace Amba {\n namespace collections {\n${interfaces ? indent(interfaces, 6) : " // (no collections defined yet)"}\n }\n }\n}\n${augmentClient}
|
|
3139
|
+
`).join("") : "";
|
|
3140
|
+
return `${banner}\n\nexport {};\n\ndeclare global {\n namespace Amba {\n namespace collections {\n${interfaces ? indent(interfaces, 6) : " // (no collections defined yet)"}\n }\n }\n}\n${augmentClient}`;
|
|
3144
3141
|
}
|
|
3145
3142
|
function emitInterface(c) {
|
|
3146
3143
|
const fields = c.columns.map((col) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layers/amba",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "amba — agent-native backend-as-a-service. Functions, collections, storage, AI
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "amba — agent-native backend-as-a-service. Functions, collections, storage, AI, email, queues, sites — one CLI to spin up your project and ship to production. `npx @layers/amba init` to start.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"amba": "dist/index.js"
|
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
"homepage": "https://amba.dev",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/layers/amba
|
|
22
|
+
"url": "git+https://github.com/layers/amba.git",
|
|
23
|
+
"directory": "packages/cli"
|
|
23
24
|
},
|
|
24
25
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/layers/amba
|
|
26
|
+
"url": "https://github.com/layers/amba/issues"
|
|
26
27
|
},
|
|
27
28
|
"license": "Apache-2.0",
|
|
28
29
|
"keywords": [
|
|
@@ -30,12 +31,11 @@
|
|
|
30
31
|
"baas",
|
|
31
32
|
"backend",
|
|
32
33
|
"cli",
|
|
33
|
-
"cloudflare-workers",
|
|
34
|
-
"neon",
|
|
35
|
-
"postgres",
|
|
36
34
|
"agent",
|
|
37
35
|
"functions",
|
|
38
|
-
"collections"
|
|
36
|
+
"collections",
|
|
37
|
+
"storage",
|
|
38
|
+
"ai"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"commander": "^13.1.0",
|