@enterstellar-ai/adapters 0.1.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/LICENSE +196 -0
- package/NOTICE +17 -0
- package/README.md +181 -0
- package/dist/index.cjs +323 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +769 -0
- package/dist/index.d.ts +769 -0
- package/dist/index.js +307 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and derivative works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
81
|
+
Contribution embodied within the Work constitutes direct or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under
|
|
83
|
+
this License for that Work shall terminate as of the date such
|
|
84
|
+
litigation is filed.
|
|
85
|
+
|
|
86
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
+
modifications, and in Source or Object form, provided that You
|
|
89
|
+
meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
+
Works a copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices
|
|
95
|
+
stating that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
+
that You distribute, all copyright, patent, trademark, and
|
|
99
|
+
attribution notices from the Source form of the Work,
|
|
100
|
+
excluding those notices that do not pertain to any part of
|
|
101
|
+
the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, You must include a readable copy of the
|
|
105
|
+
attribution notices contained within such NOTICE file, in
|
|
106
|
+
at least one of the following places: within a NOTICE text
|
|
107
|
+
file distributed as part of the Derivative Works; within
|
|
108
|
+
the Source form or documentation, if provided along with the
|
|
109
|
+
Derivative Works; or, within a display generated by the
|
|
110
|
+
Derivative Works, if and wherever such third-party notices
|
|
111
|
+
normally appear. The contents of the NOTICE file are for
|
|
112
|
+
informational purposes only and do not modify the License.
|
|
113
|
+
You may add Your own attribution notices within Derivative
|
|
114
|
+
Works that You distribute, alongside or as an addendum to
|
|
115
|
+
the NOTICE text from the Work, provided that such additional
|
|
116
|
+
attribution notices cannot be construed as modifying the
|
|
117
|
+
License.
|
|
118
|
+
|
|
119
|
+
You may add Your own license statement to Your modifications and
|
|
120
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
121
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
122
|
+
Modifications or such Derivative Works, and to permit recipients
|
|
123
|
+
of the Modifications to such Derivative Works to do so, subject to
|
|
124
|
+
the terms of the License.
|
|
125
|
+
|
|
126
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
127
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
128
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
129
|
+
this License, without any additional terms or conditions.
|
|
130
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
131
|
+
the terms of any separate license agreement you may have executed
|
|
132
|
+
with Licensor regarding such Contributions.
|
|
133
|
+
|
|
134
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
135
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
136
|
+
except as required for reasonable and customary use in describing the
|
|
137
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
138
|
+
|
|
139
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
140
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
141
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
142
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
143
|
+
implied, including, without limitation, any warranties or conditions
|
|
144
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
145
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
146
|
+
appropriateness of using or reproducing the Work and assume any
|
|
147
|
+
risks associated with Your exercise of permissions under this License.
|
|
148
|
+
|
|
149
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
150
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
151
|
+
unless required by applicable law (such as deliberate and grossly
|
|
152
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
153
|
+
liable to You for damages, including any direct, indirect, special,
|
|
154
|
+
incidental, or exemplary damages of any character arising as a
|
|
155
|
+
result of this License or out of the use or inability to use the
|
|
156
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
157
|
+
work stoppage, computer failure or malfunction, or all other
|
|
158
|
+
commercial damages or losses), even if such Contributor has been
|
|
159
|
+
advised of the possibility of such damages.
|
|
160
|
+
|
|
161
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
162
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
163
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
164
|
+
or other liability obligations and/or rights consistent with this
|
|
165
|
+
License. However, in accepting such obligations, You may offer such
|
|
166
|
+
obligations only on Your own behalf and on Your sole responsibility,
|
|
167
|
+
not on behalf of any other Contributor, and only if You agree to
|
|
168
|
+
indemnify, defend, and hold each Contributor harmless for any
|
|
169
|
+
liability incurred by, or claims asserted against, such Contributor
|
|
170
|
+
by reason of your accepting any such warranty or additional liability.
|
|
171
|
+
|
|
172
|
+
END OF TERMS AND CONDITIONS
|
|
173
|
+
|
|
174
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
175
|
+
|
|
176
|
+
To apply the Apache License to your work, attach the following
|
|
177
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
178
|
+
replaced with your own identifying information. (Do not include
|
|
179
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
180
|
+
comment syntax for the file format in question. Please also
|
|
181
|
+
make a list of the licenses used in the work and ask the
|
|
182
|
+
maintainers for clarification if needed.
|
|
183
|
+
|
|
184
|
+
Copyright 2026 LifeOS Frameworks, Inc. (DBA Enterstellar) and A. Yassin
|
|
185
|
+
|
|
186
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
187
|
+
you may not use this file except in compliance with the License.
|
|
188
|
+
You may obtain a copy of the License at
|
|
189
|
+
|
|
190
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
191
|
+
|
|
192
|
+
Unless required by applicable law or agreed to in writing, software
|
|
193
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
194
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
195
|
+
See the License for the specific language governing permissions and
|
|
196
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Enterstellar
|
|
2
|
+
Copyright 2026 LifeOS Frameworks, Inc. (DBA Enterstellar) and A. Yassin
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (the "License").
|
|
5
|
+
You may not use this product except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
11
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
12
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
13
|
+
specific language governing permissions and limitations under the License.
|
|
14
|
+
|
|
15
|
+
For licensing inquiries, contact: legal@enterstellar.dev
|
|
16
|
+
Homepage: https://enterstellar.dev
|
|
17
|
+
Repository: https://github.com/enterstellar-ai/enterstellar
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# @enterstellar-ai/adapters
|
|
2
|
+
|
|
3
|
+
> Pluggable infrastructure adapters — auth, data, error handling, analytics.
|
|
4
|
+
|
|
5
|
+
This package provides **factory functions** for creating validated adapter instances that bridge Enterstellar components to external services. Every adapter method is wrapped in error handling (AD5) — raw vendor errors never leak to consumers. The package is framework-agnostic (L15) and exports only interfaces and factories, not concrete implementations.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import {
|
|
11
|
+
createAuthAdapter,
|
|
12
|
+
createDataAdapter,
|
|
13
|
+
createErrorAdapter,
|
|
14
|
+
createAnalyticsAdapter,
|
|
15
|
+
} from '@enterstellar-ai/adapters';
|
|
16
|
+
|
|
17
|
+
// 1. Create adapters with your implementations
|
|
18
|
+
const auth = createAuthAdapter({
|
|
19
|
+
name: 'supabase-auth',
|
|
20
|
+
getSession: async () => {
|
|
21
|
+
const { data } = await supabase.auth.getSession();
|
|
22
|
+
if (!data.session) return null;
|
|
23
|
+
return { userId: data.session.user.id, roles: ['clinician'] };
|
|
24
|
+
},
|
|
25
|
+
hasRole: async (role) => {
|
|
26
|
+
const session = await supabase.auth.getSession();
|
|
27
|
+
return session.data.session?.user.role === role;
|
|
28
|
+
},
|
|
29
|
+
onAuthChange: (cb) => {
|
|
30
|
+
const { data } = supabase.auth.onAuthStateChange((_event, session) => {
|
|
31
|
+
cb(session ? { userId: session.user.id, roles: ['clinician'] } : null);
|
|
32
|
+
});
|
|
33
|
+
return () => data.subscription.unsubscribe();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const data = createDataAdapter({
|
|
38
|
+
name: 'supabase-data',
|
|
39
|
+
query: async (resource, params) => {
|
|
40
|
+
const { data } = await supabase
|
|
41
|
+
.from(resource)
|
|
42
|
+
.select('*')
|
|
43
|
+
.match(params ?? {});
|
|
44
|
+
return data ?? [];
|
|
45
|
+
},
|
|
46
|
+
mutate: async (resource, action, payload) => {
|
|
47
|
+
if (action === 'create') {
|
|
48
|
+
const { data } = await supabase.from(resource).insert(payload).select().single();
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
subscribe: (resource, callback) => {
|
|
54
|
+
const channel = supabase
|
|
55
|
+
.channel(resource)
|
|
56
|
+
.on('postgres_changes', { event: '*', schema: 'public', table: resource }, () => {
|
|
57
|
+
data.query(resource).then(callback);
|
|
58
|
+
})
|
|
59
|
+
.subscribe();
|
|
60
|
+
return () => {
|
|
61
|
+
void supabase.removeChannel(channel);
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// 2. Pass adapters to Provider
|
|
67
|
+
// <Provider adapters={{ auth, data }} ... />
|
|
68
|
+
|
|
69
|
+
// 3. For testing, use noop adapters
|
|
70
|
+
import { createNoopAuthAdapter, createNoopDataAdapter } from '@enterstellar-ai/adapters';
|
|
71
|
+
const testAuth = createNoopAuthAdapter(); // getSession → null, hasRole → false
|
|
72
|
+
const testData = createNoopDataAdapter(); // query → [], mutate → null
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## API Reference
|
|
76
|
+
|
|
77
|
+
### Factories
|
|
78
|
+
|
|
79
|
+
| Function | Returns | Description |
|
|
80
|
+
| :------------------------------- | :----------------- | :-------------------------------------------------------------------- |
|
|
81
|
+
| `createAuthAdapter(config)` | `AuthAdapter` | Validates config, wraps methods in AD5 error handling. Frozen object. |
|
|
82
|
+
| `createDataAdapter(config)` | `DataAdapter` | Validates config, wraps query/mutate/subscribe. Frozen object. |
|
|
83
|
+
| `createErrorAdapter(config)` | `ErrorAdapter` | Validates config, wraps report/shouldRetry/sanitize. Frozen object. |
|
|
84
|
+
| `createAnalyticsAdapter(config)` | `AnalyticsAdapter` | Validates config, wraps track/identify. Frozen object. |
|
|
85
|
+
|
|
86
|
+
### Noop Factories (Testing & Development)
|
|
87
|
+
|
|
88
|
+
| Function | Returns | Description |
|
|
89
|
+
| :----------------------------- | :----------------- | :----------------------------------------------------------------------------- |
|
|
90
|
+
| `createNoopAuthAdapter()` | `AuthAdapter` | `getSession` → `null`, `hasRole` → `false`, `onAuthChange` → noop unsubscribe. |
|
|
91
|
+
| `createNoopDataAdapter()` | `DataAdapter` | `query` → `[]`, `mutate` → `null`, `subscribe` → noop unsubscribe. |
|
|
92
|
+
| `createNoopErrorAdapter()` | `ErrorAdapter` | `report` → void, `shouldRetry` → `false`, `sanitize` → identity. All async. |
|
|
93
|
+
| `createNoopAnalyticsAdapter()` | `AnalyticsAdapter` | `track` → void, `identify` → void. |
|
|
94
|
+
|
|
95
|
+
### Error Factories (ENS-7001–7005)
|
|
96
|
+
|
|
97
|
+
| Code | Factory | Trigger | Recoverable |
|
|
98
|
+
| :--------- | :------------------------- | :---------------------------------------------- | :---------- |
|
|
99
|
+
| `ENS-7001` | `adapterValidationError()` | Config missing required methods or invalid name | No |
|
|
100
|
+
| `ENS-7002` | `adapterMethodError()` | Adapter method threw during execution | Yes |
|
|
101
|
+
| `ENS-7003` | `adapterQueryError()` | DataAdapter `query()` failed | Yes |
|
|
102
|
+
| `ENS-7004` | `adapterMutationError()` | DataAdapter `mutate()` failed | Yes |
|
|
103
|
+
| `ENS-7005` | `adapterAuthError()` | AuthAdapter session/role check failed | Yes |
|
|
104
|
+
|
|
105
|
+
### Validation Utility
|
|
106
|
+
|
|
107
|
+
| Function | Returns | Description |
|
|
108
|
+
| :------------------------------------ | :------ | :-------------------------------------------------------------------------------------- |
|
|
109
|
+
| `validateAdapterConfig(type, config)` | `void` | Validates name (non-empty string) + required methods (typeof check). Throws `ENS-7001`. |
|
|
110
|
+
|
|
111
|
+
### Adapter Interfaces (re-exported from `@enterstellar-ai/types`)
|
|
112
|
+
|
|
113
|
+
| Interface | Methods |
|
|
114
|
+
| :----------------- | :-------------------------------------------------------------------------------------------- |
|
|
115
|
+
| `AuthAdapter` | `getSession()`, `hasRole(role)`, `onAuthChange(cb)` |
|
|
116
|
+
| `DataAdapter` | `query(resource, params?)`, `mutate(resource, action, data)`, `subscribe(resource, callback)` |
|
|
117
|
+
| `ErrorAdapter` | `report(error, context?)`, `shouldRetry(error, attempt)`, `sanitize(error)` |
|
|
118
|
+
| `AnalyticsAdapter` | `track(event, properties?)`, `identify(userId, traits?)` |
|
|
119
|
+
|
|
120
|
+
### Exported Types
|
|
121
|
+
|
|
122
|
+
| Type | Description |
|
|
123
|
+
| :----------------------- | :-------------------------------------------------------------------------------- | ------ | ------- | ---------------------------------------------------- |
|
|
124
|
+
| `AuthAdapterConfig` | Config for `createAuthAdapter()`: `name` + auth method implementations. |
|
|
125
|
+
| `DataAdapterConfig` | Config for `createDataAdapter()`: `name` + data method implementations. |
|
|
126
|
+
| `ErrorAdapterConfig` | Config for `createErrorAdapter()`: `name` + error method implementations. |
|
|
127
|
+
| `AnalyticsAdapterConfig` | Config for `createAnalyticsAdapter()`: `name` + analytics method implementations. |
|
|
128
|
+
| `AdapterType` | `'auth' | 'data' | 'error' | 'analytics'` — discriminator for adapter categories. |
|
|
129
|
+
| `ADAPTERS_VERSION` | Semver string matching `package.json`. |
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
### Config Objects (passed to factories)
|
|
134
|
+
|
|
135
|
+
Every adapter config requires a `name` (non-empty string) plus all methods defined by the corresponding `@enterstellar-ai/types` interface.
|
|
136
|
+
|
|
137
|
+
| Config | Required Methods | Async/Sync |
|
|
138
|
+
| :----------------------- | :-------------------------------------- | :---------------------------------------------------------------- |
|
|
139
|
+
| `AuthAdapterConfig` | `getSession`, `hasRole`, `onAuthChange` | getSession/hasRole async, onAuthChange sync (returns unsubscribe) |
|
|
140
|
+
| `DataAdapterConfig` | `query`, `mutate`, `subscribe` | query/mutate async, subscribe sync |
|
|
141
|
+
| `ErrorAdapterConfig` | `report`, `shouldRetry`, `sanitize` | All async (AD2) |
|
|
142
|
+
| `AnalyticsAdapterConfig` | `track`, `identify` | Both sync (fire-and-forget) |
|
|
143
|
+
|
|
144
|
+
### AD5 Error Wrapping
|
|
145
|
+
|
|
146
|
+
All factories wrap consumer methods in error handling per Design Choice AD5:
|
|
147
|
+
|
|
148
|
+
- `getSession()` / `hasRole()` → `ENS-7005` (auth-specific)
|
|
149
|
+
- `onAuthChange()` → `ENS-7002` (subscription management)
|
|
150
|
+
- `query()` → `ENS-7003` (includes resource name)
|
|
151
|
+
- `mutate()` → `ENS-7004` (includes resource + action)
|
|
152
|
+
- `subscribe()` / `track()` / `identify()` / `report()` / `shouldRetry()` / `sanitize()` → `ENS-7002`
|
|
153
|
+
|
|
154
|
+
Original errors are preserved in `cause` for debugging.
|
|
155
|
+
|
|
156
|
+
### Design Choices Applied
|
|
157
|
+
|
|
158
|
+
| Decision | Rule |
|
|
159
|
+
| :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
160
|
+
| AD1 | Minimal but complete: `getSession`, `hasRole`, `onAuthChange`. `signIn`/`signOut` are NOT adapter concerns. |
|
|
161
|
+
| AD2 | Async-by-default for I/O methods. Sync for fire-and-forget (`track`, `identify`). `shouldRetry`/`sanitize` are async (future: circuit breakers, PII detection). |
|
|
162
|
+
| AD3 | Convention-based dot-notation (`patients.vitals`) for resource identifiers. |
|
|
163
|
+
| AD5 | Wrap into EnterstellarError — raw vendor errors never leak. |
|
|
164
|
+
| R1 | Plain objects with closures — no class instances. |
|
|
165
|
+
| R4 | `Object.freeze()` on all returned adapters. |
|
|
166
|
+
| L15 | Zero framework dependencies. Engine-only package. |
|
|
167
|
+
|
|
168
|
+
### Build Configuration
|
|
169
|
+
|
|
170
|
+
| File | Purpose |
|
|
171
|
+
| :--------------- | :----------------------------------------------------------------------------------------- |
|
|
172
|
+
| `tsconfig.json` | Extends `tsconfig.base.json` — 15 strict flags. Overrides `composite: false` for tsup DTS. |
|
|
173
|
+
| `tsup.config.ts` | Builds ESM + CJS + DTS. Single entry: `src/index.ts`. |
|
|
174
|
+
|
|
175
|
+
**Peer dependencies:** `@enterstellar-ai/types`
|
|
176
|
+
|
|
177
|
+
## See Also
|
|
178
|
+
|
|
179
|
+
- [Implementation Bible §4.15](../../agent/03-enterstellar-implementation-bible.md) — adapter layer specification.
|
|
180
|
+
- [Design Choices — Adapters](../../agent/04-enterstellar-design-choices.md) — locked decisions AD1–AD5.
|
|
181
|
+
- [Coding Rules](../../agent/05-enterstellar-coding-rules.md) — naming conventions, strictness requirements.
|