@adaptic/backend-legacy 0.0.1026 → 0.0.1027
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/README.md +27 -13
- package/client.cjs +1 -1
- package/client.d.ts +1 -1
- package/esm/auth/token-verifier.d.ts +1 -1
- package/esm/auth/token-verifier.mjs +1 -1
- package/esm/client.d.ts +1 -1
- package/esm/client.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
# @adaptic/backend
|
|
1
|
+
# @adaptic/backend
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
> **This package was previously published as `@adaptic/backend-legacy`.**
|
|
6
|
+
> It is now `@adaptic/backend`. Both names are published from the same build, at the
|
|
7
|
+
> same version, with byte-identical contents, so the change is a pure rename — no API
|
|
8
|
+
> difference and no behavioural difference between them. Migrate with:
|
|
9
|
+
>
|
|
10
|
+
> ```bash
|
|
11
|
+
> npm install @adaptic/backend && npm uninstall @adaptic/backend-legacy
|
|
12
|
+
> ```
|
|
13
|
+
>
|
|
14
|
+
> then replace the specifier `@adaptic/backend-legacy` with `@adaptic/backend` in your
|
|
15
|
+
> imports (subpaths such as `/server/index` are unchanged). `@adaptic/backend-legacy`
|
|
16
|
+
> keeps publishing until every consumer has moved, and every version of it that has
|
|
17
|
+
> ever been published stays installable — it will never be unpublished.
|
|
18
|
+
|
|
5
19
|
## Description
|
|
6
20
|
|
|
7
|
-
The `@adaptic/backend
|
|
21
|
+
The `@adaptic/backend` NPM package provides a comprehensive set of executable CRUD (Create, Read, Update, Delete) functions, type and enums definitions, tailored for the Adaptic AI platform. Designed for both client-side and server-side applications, it leverages the power of **Apollo Client** for GraphQL interactions, and **TypeGraphQL** for building type-safe APIs.
|
|
8
22
|
|
|
9
23
|
It's primary goal, is to enabled developers to quickly scaffold and interact with their data models, without the need to write elaborate gql operations, or lack certainty of what data to pass through as variables or arguments. Rather, the executable CRUD functions are generated dynamically based on the models defined in the project, and are accessible under the global `adaptic` namespace. Rather than requiring various inputTypes, you simply pass through the data as an object that conforms to the corresponding model's type definition, and the package will handle the rest, irrespective of mutation or query operation being performed.
|
|
10
24
|
|
|
@@ -26,7 +40,7 @@ This package offers a robust backend solution tailored for the Adaptic AI platfo
|
|
|
26
40
|
|
|
27
41
|
## Prerequisites
|
|
28
42
|
|
|
29
|
-
To use the `@adaptic/backend
|
|
43
|
+
To use the `@adaptic/backend` package, the only requirement is to ensure you have several environment variables configured (see below). This can be a local development server or a production endpoints for the graphql server, and the corresponding HTTPS and WebSocket URLs.
|
|
30
44
|
|
|
31
45
|
### Environment Variables
|
|
32
46
|
|
|
@@ -44,12 +58,12 @@ BACKEND_WS_URL=wss://api.example.com/subscriptions
|
|
|
44
58
|
|
|
45
59
|
## Installation
|
|
46
60
|
|
|
47
|
-
To install the `@adaptic/backend
|
|
61
|
+
To install the `@adaptic/backend` package, follow these steps:
|
|
48
62
|
|
|
49
63
|
1. **Install NPM Package**:
|
|
50
64
|
|
|
51
65
|
```bash
|
|
52
|
-
npm @adaptic/backend
|
|
66
|
+
npm install @adaptic/backend
|
|
53
67
|
```
|
|
54
68
|
|
|
55
69
|
2. **Set Up Environment Variables**:
|
|
@@ -68,7 +82,7 @@ All the dynamically generated functions for each content model are available und
|
|
|
68
82
|
|
|
69
83
|
```typescript
|
|
70
84
|
// client-side/index.ts
|
|
71
|
-
import adaptic, { types, enums } from '@adaptic/backend
|
|
85
|
+
import adaptic, { types, enums } from '@adaptic/backend';
|
|
72
86
|
|
|
73
87
|
export const main = async () => {
|
|
74
88
|
// Example: Create a new User
|
|
@@ -111,11 +125,11 @@ export const main = async () => {
|
|
|
111
125
|
|
|
112
126
|
#### Server-Side Usage (Within a Lambda Function)
|
|
113
127
|
|
|
114
|
-
The only difference between client-side and server-side usage is the import statement. On the server-side, you import the functions from `@adaptic/backend
|
|
128
|
+
The only difference between client-side and server-side usage is the import statement. On the server-side, you import the functions from `@adaptic/backend/server/index` instead of `@adaptic/backend`, and you need to provide an Apollo Client instance to the functions with the use of 'fetch' for the HTTP link.
|
|
115
129
|
|
|
116
130
|
```javascript
|
|
117
131
|
// server-side/lambdaFunction.mjs
|
|
118
|
-
import adaptic from '@adaptic/backend
|
|
132
|
+
import adaptic from '@adaptic/backend/server/index';
|
|
119
133
|
|
|
120
134
|
export const handler = async (event) => {
|
|
121
135
|
// Parse the incoming event data
|
|
@@ -174,7 +188,7 @@ Types associated with your data models are available under the `types` namespace
|
|
|
174
188
|
|
|
175
189
|
```typescript
|
|
176
190
|
// types-example.ts
|
|
177
|
-
import { types } from '@adaptic/backend
|
|
191
|
+
import { types } from '@adaptic/backend';
|
|
178
192
|
|
|
179
193
|
// Define a new user
|
|
180
194
|
const newUser: types.UserCreateInput = {
|
|
@@ -197,7 +211,7 @@ Enums associated with your data models are available under the `enums` namespace
|
|
|
197
211
|
|
|
198
212
|
```typescript
|
|
199
213
|
// enums-example.ts
|
|
200
|
-
import { enums } from '@adaptic/backend
|
|
214
|
+
import { enums } from '@adaptic/backend';
|
|
201
215
|
|
|
202
216
|
// Assign a user role
|
|
203
217
|
const userRole: enums.UserRole = enums.UserRole.MODERATOR;
|
|
@@ -217,7 +231,7 @@ Their purpose is to provide a reference to the type of data being requested, whi
|
|
|
217
231
|
```typescript
|
|
218
232
|
// typeStrings-example.ts
|
|
219
233
|
|
|
220
|
-
import { typeStrings } from '@adaptic/backend
|
|
234
|
+
import { typeStrings } from '@adaptic/backend';
|
|
221
235
|
|
|
222
236
|
// Use typeStrings in a prompt being sent to an LLM
|
|
223
237
|
const prompt = `
|
|
@@ -231,7 +245,7 @@ const prompt = `
|
|
|
231
245
|
|
|
232
246
|
### Model CRUD Resolvers
|
|
233
247
|
|
|
234
|
-
The `@adaptic/backend
|
|
248
|
+
The `@adaptic/backend` package includes a comprehensive set of CRUD (Create, Read, Update, Delete) resolvers for each of your models. Each model has the following functions:
|
|
235
249
|
|
|
236
250
|
- `ModelName.create`: Create a single record.
|
|
237
251
|
- `ModelName.createMany`: Create multiple records.
|
|
@@ -243,7 +257,7 @@ The `@adaptic/backend-legacy` package includes a comprehensive set of CRUD (Crea
|
|
|
243
257
|
|
|
244
258
|
### Model TypeStrings, Types, and available CRUD Resolvers
|
|
245
259
|
|
|
246
|
-
The `@adaptic/backend
|
|
260
|
+
The `@adaptic/backend` package includes a comprehensive set of CRUD (Create, Read, Update, Delete) resolvers for each of your models. Each model has the following functions (available directly under the `adaptic` namespace) and types (under the `types` namespace):
|
|
247
261
|
|
|
248
262
|
| Model Name | TypeString | Type | CRUD Resolvers |
|
|
249
263
|
|------------|------------|------------|-----------------|
|
package/client.cjs
CHANGED
|
@@ -744,7 +744,7 @@ async function getApolloModules() {
|
|
|
744
744
|
* awaited (or used in `Promise.all`). Previously this was `getApolloClient()` which
|
|
745
745
|
* eagerly opened a connection at module-load time, before any pool configuration or
|
|
746
746
|
* auth token provider was set, causing orphaned connections in every process that
|
|
747
|
-
* imported `@adaptic/backend
|
|
747
|
+
* imported `@adaptic/backend`.
|
|
748
748
|
*
|
|
749
749
|
* @deprecated Prefer calling `getApolloClient()` directly for explicit lifecycle control.
|
|
750
750
|
*/
|
package/client.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export declare function getApolloModules(): Promise<ApolloModules>;
|
|
|
114
114
|
* awaited (or used in `Promise.all`). Previously this was `getApolloClient()` which
|
|
115
115
|
* eagerly opened a connection at module-load time, before any pool configuration or
|
|
116
116
|
* auth token provider was set, causing orphaned connections in every process that
|
|
117
|
-
* imported `@adaptic/backend
|
|
117
|
+
* imported `@adaptic/backend`.
|
|
118
118
|
*
|
|
119
119
|
* @deprecated Prefer calling `getApolloClient()` directly for explicit lifecycle control.
|
|
120
120
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `verifyBackendToken` is the SOLE entry point for establishing principal
|
|
5
5
|
* identity from a bearer token presented at the GraphQL HTTP, GraphQL WebSocket,
|
|
6
|
-
* or Express middleware layer of `@adaptic/backend
|
|
6
|
+
* or Express middleware layer of `@adaptic/backend`.
|
|
7
7
|
*
|
|
8
8
|
* It rejects, in priority order:
|
|
9
9
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `verifyBackendToken` is the SOLE entry point for establishing principal
|
|
5
5
|
* identity from a bearer token presented at the GraphQL HTTP, GraphQL WebSocket,
|
|
6
|
-
* or Express middleware layer of `@adaptic/backend
|
|
6
|
+
* or Express middleware layer of `@adaptic/backend`.
|
|
7
7
|
*
|
|
8
8
|
* It rejects, in priority order:
|
|
9
9
|
*
|
package/esm/client.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export declare function getApolloModules(): Promise<ApolloModules>;
|
|
|
114
114
|
* awaited (or used in `Promise.all`). Previously this was `getApolloClient()` which
|
|
115
115
|
* eagerly opened a connection at module-load time, before any pool configuration or
|
|
116
116
|
* auth token provider was set, causing orphaned connections in every process that
|
|
117
|
-
* imported `@adaptic/backend
|
|
117
|
+
* imported `@adaptic/backend`.
|
|
118
118
|
*
|
|
119
119
|
* @deprecated Prefer calling `getApolloClient()` directly for explicit lifecycle control.
|
|
120
120
|
*/
|
package/esm/client.mjs
CHANGED
|
@@ -700,7 +700,7 @@ export async function getApolloModules() {
|
|
|
700
700
|
* awaited (or used in `Promise.all`). Previously this was `getApolloClient()` which
|
|
701
701
|
* eagerly opened a connection at module-load time, before any pool configuration or
|
|
702
702
|
* auth token provider was set, causing orphaned connections in every process that
|
|
703
|
-
* imported `@adaptic/backend
|
|
703
|
+
* imported `@adaptic/backend`.
|
|
704
704
|
*
|
|
705
705
|
* @deprecated Prefer calling `getApolloClient()` directly for explicit lifecycle control.
|
|
706
706
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptic/backend-legacy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1027",
|
|
4
4
|
"description": "Backend executable CRUD functions with dynamic variables construction, and type definitions for the Adaptic AI platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "index.d.ts",
|