@memberjunction/data-context-server 6.2.0-edge.7 → 6.2.0
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/package.json +4 -4
- package/readme.md +0 -60
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/data-context-server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.2.0
|
|
4
|
+
"version": "6.2.0",
|
|
5
5
|
"description": "This library provides a server-side implementation of the DataContextItem class from @memberjunction/data-context that can handle the server-side only use case of loading data into a context using raw SQL statements.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typescript": "^5.9.3"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/core": "6.2.0
|
|
19
|
-
"@memberjunction/data-context": "6.2.0
|
|
20
|
-
"@memberjunction/global": "6.2.0
|
|
18
|
+
"@memberjunction/core": "6.2.0",
|
|
19
|
+
"@memberjunction/data-context": "6.2.0",
|
|
20
|
+
"@memberjunction/global": "6.2.0",
|
|
21
21
|
"mssql": "^12.2.0"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
package/readme.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# @memberjunction/data-context-server
|
|
2
|
-
|
|
3
|
-
Server-side implementation of the MemberJunction Data Context system. Loads the data of `sql`-type `DataContextItem` objects by running their SQL through a query provider's screened ad-hoc path.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The `@memberjunction/data-context-server` package extends the base `DataContextItem` class from `@memberjunction/data-context` with a server-side implementation of `LoadFromSQL`. It runs the item's SQL through `RunQuery({ SQL })` on a query provider, the same ad-hoc path `ExecuteAdhocQuery` uses, so the SQL must be a single read statement. On PostgreSQL that path also runs it in a read-only transaction that is rolled back. It never sends SQL to a raw connection pool. This is the server counterpart to the client-side GraphQL-based data context loading.
|
|
8
|
-
|
|
9
|
-
```mermaid
|
|
10
|
-
graph TD
|
|
11
|
-
A["DataContextItemServer"] -->|extends| B["DataContextItem<br/>(data-context package)"]
|
|
12
|
-
A -->|"RunQuery({ SQL })"| C["Read-only query provider"]
|
|
13
|
-
C --> D["Database"]
|
|
14
|
-
|
|
15
|
-
E["Server-Side Code<br/>(MJAPI, Actions, etc.)"] --> A
|
|
16
|
-
F["Client-Side Code<br/>(Angular, React)"] --> G["DataContextItemClient<br/>(GraphQL-based)"]
|
|
17
|
-
|
|
18
|
-
style A fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
19
|
-
style B fill:#7c5295,stroke:#563a6b,color:#fff
|
|
20
|
-
style C fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
21
|
-
style D fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
22
|
-
style E fill:#b8762f,stroke:#8a5722,color:#fff
|
|
23
|
-
style G fill:#b8762f,stroke:#8a5722,color:#fff
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Installation
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install @memberjunction/data-context-server
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## How It Works
|
|
33
|
-
|
|
34
|
-
The package registers `DataContextItemServer` as a subclass of `DataContextItem` using MemberJunction's `@RegisterClass` decorator. When server-side code creates a `DataContextItem`, the class factory automatically returns the server implementation.
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import '@memberjunction/data-context-server';
|
|
38
|
-
// DataContextItem instances can now load `sql` items on the server
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The `LoadFromSQL` method:
|
|
42
|
-
1. Receives a query provider (`IRunQueryProvider`) as the data source. MJServer passes its read-only provider.
|
|
43
|
-
2. Refuses when there is no context user, or when the data source is not a query provider (for example a raw connection pool)
|
|
44
|
-
3. Runs `DataContextItem.SQL` through `RunQuery({ SQL })` for the context user. The provider accepts only a single read statement.
|
|
45
|
-
4. Stores the result rows in `DataContextItem.Data`
|
|
46
|
-
5. Returns success/failure with error details on `DataLoadingError`
|
|
47
|
-
|
|
48
|
-
Callers decide who may run an item's SQL. MJServer's `GetDataContextData` and `GetDataContextItemData` queries allow it only for the data context's owner or an administrator, never for a scope-limited session, and only on the read-only provider.
|
|
49
|
-
|
|
50
|
-
## Dependencies
|
|
51
|
-
|
|
52
|
-
| Package | Purpose |
|
|
53
|
-
|---------|---------|
|
|
54
|
-
| `@memberjunction/core` | `IRunQueryProvider`, `UserInfo`, `LogError` |
|
|
55
|
-
| `@memberjunction/global` | RegisterClass decorator |
|
|
56
|
-
| `@memberjunction/data-context` | Base DataContextItem class |
|
|
57
|
-
|
|
58
|
-
## License
|
|
59
|
-
|
|
60
|
-
Business Source License 1.1 — see [LICENSE](../../LICENSE) for details.
|